在使用android layout xml时,我遇到了backgroundTint
属性。我不明白这是做什么用的。
还有什么是backgroundTintMode
??
发布于 2016-06-28 23:31:57
我测试了android:background
、android:backgroundTint
和android:backgroundTintMode
的各种组合。
当与android:background
一起使用时,android:backgroundTint
会将滤色器应用于android:backgroundTintMode
的资源。
结果如下:
如果你想做进一步的实验,下面是代码:
<?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>
发布于 2015-09-09 13:16:14
backgroundTint
属性将帮助您为背景添加色调(阴影)。您可以以- "#rgb", "#argb", "#rrggbb", or "#aarrggbb".
的形式为其提供颜色值
另一方面,backgroundTintMode
将帮助您应用背景色调。它必须具有常量值,如src_over, src_in, src_atop,
等。
参考this可以清楚地了解可以使用的常量值。搜索backgroundTint
属性和描述以及各种属性将可用。
发布于 2015-09-09 13:25:25
BackgroundTint用作滤色器。
FEFBDE作为色调
37AEE4作为背景
尝试通过注释色调/背景来查看不同之处,并在两者都设置时检查输出。
https://stackoverflow.com/questions/32471009
复制相似问题