Is there a way to avoid the size specifications in the Android layout?

Asked

Viewed 79 times

2

I work with Android on a day-to-day basis, and I would like to avoid the size specs views. For example: If I make a TextView, i have to assign Height and Width properties, so:

<TextView
      android:id="@+id/activity_lbl"
      android:layout_width="wrap_content" <!-- Novamente -->
      android:layout_height="wrap_content" <!-- Novamente...  --> /> 

   <TextView
      android:id="@+id/activity_lbl2"
      android:layout_width="wrap_content" <!-- Novamente... -->
      android:layout_height="wrap_content" <!-- Novamente....  --> /> 

There is a way to avoid the size specifications in the Android layout?

1 answer

5


You can define one or several "Styles" for your project

Ex. Your Textview will look like this:

<TextView style="@style/TextWidth" android:text="@string/textOne" />

Your style will look like this:

<style name="TextWidth">
    <item name="android:layout_width">match_parent</item>
    <item name="android:layout_height">match_parent</item>
</style>

Source: Blog Caelum

Browser other questions tagged

You are not signed in. Login or sign up in order to post.