Lingviston
Lingviston

Reputation: 5671

Style which uses references attr in app widget

I have AppTheme with some custom stylable attributes. For example attr1. I have style:

<style name="Style1">
    <item name="android:background">?attr/attr1</item>
</style>

When I use this style inside my activity layour for example it works fine. But when I'm using this style in app widget layout - it can't be instantiated. What am I doing wrong?

P.S. android:attr reference works fine in app widget.

Upvotes: 1

Views: 302

Answers (2)

Amir
Amir

Reputation: 1268

you can't use your app resources for appWidget, they have separate context
you can only use remoteViews for styling

Upvotes: 3

alijandro
alijandro

Reputation: 12147

The background is a drawable, did you try replace it with drawable or color resources?

<style name="Style1">
    <item name="android:background">@drawable/background</item>
    <item name="android:background">@color/background</item>
</style>

Upvotes: 0

Related Questions