安卓开发alpha的用法

alpha:透明度,在<TextView/>中使用时既调节背景颜色的透明度,也可以调节字体颜色的透明度,取值从0(透明)到1(不透明)。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#FF000000"
>
<TextView
android:id="@+id/textview0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#CC0033"
android:alpha="0.4"
android:text="第一个"
/>

<TextView
android:id="@+id/textview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textview0"
android:background="#CC0033"
android:alpha="0.1"
android:text="第二个"/>

<TextView
android:id="@+id/textview2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textview1"
android:background="#CC0033"
android:alpha="1"
android:text="第三个"/>

</RelativeLayout>


试验结果截图:

安卓开发alpha的用法

在Android Studio中通过试验的处结论。

安卓开发alpha的用法

上一篇:banner区域图片背景注意点(移动端)


下一篇:WPF的Application类详解