Alexander
Alexander

Reputation: 48272

Confused about TextAppearance style in app compat v21

When I'm using appcompat v21 with Light.DarkActionBar theme in my app I have:

If I'm using ?android:textAppearanceMedium my text has greyish color

If I'm using @android:style/TextAppearance.Medium my text has black color

What is the difference between those two? I thought they, by definition, should be the same, the second being simply more explicit expression of the first?

Upvotes: 3

Views: 4122

Answers (1)

alanv
alanv

Reputation: 24124

The theme attribute ?android:attr/textAppearanceMedium is set by the current theme to point to a style resource. On Theme and Theme.Light, it points to @android:style/TextAppearance.Medium. On Theme.AppCompat themes, it points to @android:style/TextAppearance.AppCompat.Medium.

So when you explicitly point to @android:style/TextAppearance.Medium when your app is targeting Theme.AppCompat, you are getting the text appearance style meant for Gingerbread-themed apps. If you use ?android:attr/textAppearanceMedium instead, you will get a style meant for your current theme.

Upvotes: 6

Related Questions