Kenny Wyland
Kenny Wyland

Reputation: 21880

Android Inherit style from different layout size

Is it possible to inherit android styles from a different layout size?

For example, if I define a style named MyLabel in my "values" directory (i.e. /res/values/style.xml), it is possible to inherit from that label in a different values directory? (i.e. /res/values-large-mdpi/style.xml)

What I'm trying to do is set up a bunch of styles which control the layout of my app, but change the font sizes based on layout size and screen density. I'd like to have most of the styles in one file and then just have the font sizes in the other style files.

Upvotes: 3

Views: 1255

Answers (1)

EboMike
EboMike

Reputation: 77762

You'd have to do that in two separate files. If you have style.xml in values and values-large-mdpi, the system will automatically use the one in largi-mdpi if that applies and dismiss the other one.

If you have another one like /res/values/styles-common.xml with no counterpart in values-large-mdpi, the system will use that one.

So define all your common styles in the common file and reference them from your specialized styles.

Upvotes: 1

Related Questions