Alireza Farahani
Alireza Farahani

Reputation: 2539

Android style parent chaining unexpected result

Regarding this link, I tried to use style chain parenting but the behavior isn't what I expect. I've written my styles below

<style name="headline">
    <item name="android:textSize">@dimen/fontsize_headline</item>
</style>
<style name="white_text">
    <item name="android:textColor">@color/poinila_post_background</item>
</style>
<style name="west_side">
    <item name="android:background">@color/west_side</item>
</style>
<style name="west_side.headline"></style>
<style name="west_side.headline.white_text"> 

What I expect is a yellowish button with white text and headline text size but textColor and textSize are unchanged.

My question is: am I doing the right thing and the thing right? What's the reason for misbehavior?

Upvotes: 0

Views: 49

Answers (1)

Fabian
Fabian

Reputation: 2713

Multiple parents are not allowed in styles.

What you've done here

<style name="west_side.headline.white_text"/> 

was creating a new style called white_text with the parent west_side.headline .

To get your expected result you have to add the textcolor attribute to the new style.

<style name="west_side.headline.white_text">
    <item name="android:textColor">@color/poinila_post_background</item>
</style>

Upvotes: 1

Related Questions