Doesn't the theme apply to programmatically added views?

I set some properties in my application theme, it looks like this:

<style name="my_theme" parent="AppBaseTheme">
    <item name="android:textColor">#FF0000</item>
    <item name="android:textStyle">bold</item>
</style>

The theme is correctly applied to all views defined in the file layout activity. But if I add viewprogrammatically to the method onCreate(), these styleswill be ignored.

So, I can not use the theme for these styles views? Or am I missing something here?

+5
source share
1 answer

I think that if you create a View programmatically, this View is not attached to any creation activity, so the theme does not apply.

LayoutInflater . , .

, , - .

0

All Articles