【发布时间】:2017-07-31 16:13:41
【问题描述】:
我知道在 sdk 21 之前有很多主题讨论色调功能,但是 他们要么使用某种图像视图(我不这样做),要么以编程方式解决它(我不想这样做)。
我的情况:
我有一个约束布局,以 9-patch 可绘制为背景:
<android.support.constraint.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/testDrawable">
这是我的可绘制对象:
<nine-patch xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/ninepatchdrawable"
android:tint="@color/lightBlue"
android:tintMode="multiply" />
这适用于更新的设备,但正如我所说,色调不适用于 sdk
我已经尝试将布局更改为:
<android.support.constraint.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/testDrawable"
android:backgroundTint="@color/lightBlue"
android:backgroundTintMode="multiply">
或在另一个问题中使用 app:backgroundTint 作为建议集。
提前致谢
【问题讨论】:
-
使用
DrawableCompat#setTint(Drawable drawable, int tint)
标签: android android-layout android-drawable