Reputation: 1439
I have a question considering extending styles in android:
<style name="SomeStyleName" parent="@android:style/DeviceDefault.SegmentedButton">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:weightSum">2</item>
<item name="android:dividerPadding">8dip</item>
<item name="android:paddingTop">0dip</item>
<item name="android:paddingBottom">0dip</item>
<item name="android:paddingLeft">0dip</item>
<item name="android:paddingRight">0dip</item>
</style>
What if I would like to "extend" this default style for sw800dp and only to change one parameter (android:paddingBottom)? Should I write only the parameter? Or all the data? (in values-sw600dp/styles.xml file of course)
Something like?:
<style name="SomeStyleName" >
<item name="android:paddingBottom">33dip</item>
</style>
Upvotes: 0
Views: 854
Reputation: 117
What if I would like to "extend" this default style for sw800dp and only to change one parameter (android:paddingBottom)? Should I write only the parameter? Or all the data? (in values-sw600dp/styles.xml file of course)
you have to copy all the properties to values-sw600dp/styles.xml too.
But you can use the one values/styles.xml
for all the screen resolution with the help of values/dimens.xml
, values-sw600dp/dimens.xml
... and add a dimension for padding_bottom.
in all the dimens.xml in different values folder,use this dimen rather than hardcoding eg. android:paddingBottom="@dimen/padding_bottom"
in values/styles.xml
so your values/styles.xml look like this:-
<style name="SomeStyleName" parent="@android:style/DeviceDefault.SegmentedButton">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:weightSum">2</item>
<item name="android:dividerPadding">8dip</item>
<item name="android:paddingTop">0dip</item>
<item name="android:paddingBottom">@dimen/padding_bottom</item>
<item name="android:paddingLeft">0dip</item>
<item name="android:paddingRight">0dip</item>
values/dimens.xml
<dimen name="padding_bottom">0dp</dimen>
values-sw600dp/dimens.xml
<dimen name="padding_bottom">33dip</dimen>
So no need to create values-sw600dp/styles.xml
folder structure look like this:-
Upvotes: 1
Reputation: 8745
You can use dimens.xml in values folder And redefine needed dimensions in values-sw600dp and other
for example your main dimens.xml
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>
dimens.xml for sw800dp
<resources>
<dimen name="activity_horizontal_margin">32dp</dimen>
</resources>
Upvotes: 0