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

2

I work with Android on a day-to-day basis, and I'd like to avoid specs of size visualizations. For example: If I make a TextView , I have to assign Height and Width properties, like this:

<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....  --> /> 

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

    
asked by anonymous 04.02.2014 / 20:41

1 answer

5

You can define one or several styles for your project

Eg: 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

    
04.02.2014 / 21:03