Drawable tinting for api <21

后端 未结 10 1929
情话喂你
情话喂你 2020-11-29 01:56

Is it possible to make drawable tinting work for api < 21?



        
相关标签:
10条回答
  • 2020-11-29 02:50

    Now AppCompatImageView,AppCompatButton will replace the ImageView,Button to support tint on devices with lower API. Check link for more details AppCompatImageView,AppCompatButton

    0 讨论(0)
  • 2020-11-29 02:50

    Use this NameSpace
    xmlns:app="http://schemas.android.com/apk/res-auto"

    and after you can replace every android:tint with app:tint. This fix the issue for me.

    0 讨论(0)
  • 2020-11-29 02:52

    Use the AppCompatImageView like so:

    <android.support.v7.widget.AppCompatImageView
            android:id="@+id/my_appcompat_imageview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/my_image"
            android:tint="#636363"
        />
    

    Make sure you have the latest appcompat-v7 in your app's build.gradle.

    Example: compile 'com.android.support:appcompat-v7:25.0.0' in your app's build.gradle.

    0 讨论(0)
  • 2020-11-29 02:57

    Couldn't you simply use an ImageView to display your Drawable? android:tint works fine on older API levels.

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_calendar"
        android:tint="@color/primary"
        />
    
    0 讨论(0)
提交回复
热议问题