background,backgroundTint,android layout xml中的backgroundTintMode属性有什么区别?
在使用android layout xml时,我遇到了backgroundTint属性。 我不明白是什么
另外什么是backgroundTintMode ?
我testing了android:background , android:backgroundTint和android:backgroundTintMode各种组合。
android:backgroundTint与android:backgroundTintMode一起使用时,将颜色filter应用于android:backgroundTint的资源。
结果如下:
下面是代码,如果你想进一步试验:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:orientation="vertical" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:showIn="@layout/activity_main"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="32dp" android:textSize="45sp" android:background="#37AEE4" android:text="Background" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="32dp" android:textSize="45sp" android:backgroundTint="#FEFBDE" android:text="Background tint" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="32dp" android:textSize="45sp" android:background="#37AEE4" android:backgroundTint="#FEFBDE" android:text="Both together" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="32dp" android:textSize="45sp" android:background="#37AEE4" android:backgroundTint="#FEFBDE" android:backgroundTintMode="multiply" android:text="With tint mode" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="32dp" android:textSize="45sp" android:text="Without any" /> </LinearLayout>
backgroundTint属性将帮助您为backgroundTint添加色调(阴影)。 您可以以"#rgb", "#argb", "#rrggbb", or "#aarrggbb".的forms提供相同的颜色值"#rgb", "#argb", "#rrggbb", or "#aarrggbb".
backgroundTintMode另一方面将帮助您应用背景色调。 它必须具有像src_over, src_in, src_atop,等常数值
请参阅此处以获得可以使用的常量值的清晰概念。 searchbackgroundTint属性,并且可以使用描述以及各种属性。
BackgroundTint作为颜色filter。
FEFBDE作为色彩
37AEE4作为背景
尝试通过评论色调/背景看到差异,并检查两者都设置时的输出。
机器人:backgroundTintMode
混合模式用于应用背景色调。
机器人:backgroundTint
色调适用于背景。 必须是
#rgb,#argb#rgb,#argb或#aarrggbbforms的颜色值。这也可以是对资源的引用(forms为“@ [package:] type:name”)或主题属性(forms为“?[package:] [type:] name”),包含这种types的值。