Junior222
Junior222

Reputation: 833

Applying some styles to control

As you know in html/css you may apply some classes (and hence some styles) to the tag. It is cery convenient and i would like to have tgis opportunity in android development. Is there a way to apply some styles to one control?

Upvotes: 0

Views: 32

Answers (1)

Yes you can implement styles in your values/styles.xml

you can do something like :

<style name="MyMainStyle"> 
    <item name="android:layout_width">250dp</item>
    <item name="android:layout_height">60dp</item>
</style>

<style name="MySecondaryStyle" parent="MyMainStyle">
    <item name="android:paddingLeft">20dp</item>
</style>

As you can see you can also have parent styles. Then you can use the style in your layout.xml like so :

<Button
    style="@style/MyMainStyle"
    android:id="@+id/myButton" 
    />

Upvotes: 3

Related Questions