Reuse layout properties android studio

0

There is a way to reuse properties for the different components of the layout, but I do not remember how they were defined and assigned; Can anyone give me an example?

For example, if I have 15 TextView and assign each property android:textSize="35sp" it is not profitable, since then if I want to change the size I will have to modify all manually, this method allowed to reuse these properties as if they were a variable and then assign them to layout elements. I remember that it was within the same XML of the layout and not in the "programmatic" part.

    
asked by César Alejandro M 04.02.2018 в 00:25
source

1 answer

0

In styles.xml you define the set of properties you want to reuse:

<!-- Valor del resultado -->
<style name="cardTitleSize" parent="match_wrap">
    <item name="android:textSize">30sp</item>
    <item name="android:textColor">@color/colorTitle</item>
    <item name="android:layout_marginTop">9dp</item>
    <item name="android:gravity">center</item>
</style>

and then add it to an element in the following way:

<TextView
     android:id="@+id/ic_value"
     style="@style/cardTitleSize"
     android:text="@string/def"/>
    
answered by 04.02.2018 в 02:58