How to reference from drawable to style

后端 未结 2 1522
庸人自扰
庸人自扰 2021-01-02 09:18

My app with tabs has two themes. In each theme tabs have different images in selected and unselected state. How I can properly reference to image by theme?

For examp

2条回答
  •  我在风中等你
    2021-01-02 09:38

    You can find your answer here http://www.androidengineer.com/2010/06/using-themes-in-android-applications.html

    Edit
    (Additional information by Lukap in comments)

    1. Define one or more themes in themes.xml and set the definitions of your styles there.
    2. Define custom attributes, a.k.a. custom styles, in attrs.xml.
    3. Describe what the values of your custom styles are in styles.xml.

    But you will need read more about the attrs.xml

    ? android:attr/activatedBackgroundIndicator 
     
    

    Instead, we are referring to the value of some other attribute – activatedBackgroundIndicator – from our inherited theme. Whatever the theme defines as being the activatedBackgroundIndicator is what our background should be.

提交回复
热议问题