<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimaryDark"
tools:context=".activitys.CircleProgressActivity">
<RelativeLayout
android:alpha="0.2"
android:background="@color/white"
android:layout_centerInParent="true"
android:layout_width="100dp"
android:layout_height="100dp">
<TextView
android:alpha="0.5"
android:textColor="@color/white"
android:text="我和我的祖国"
android:layout_centerInParent="true"
android:layout_width="50dp"
android:layout_height="50dp"/>
</RelativeLayout>
</RelativeLayout>
我们发现这样什么也显示不出来,是不是意味着说明色值一样就无法显示了呢?
再看看下面这布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimaryDark"
tools:context=".activitys.CircleProgressActivity">
<RelativeLayout
android:alpha="0.2"
android:background="@color/white"
android:layout_centerInParent="true"
android:layout_width="100dp"
android:layout_height="100dp">
</RelativeLayout>
<TextView
android:alpha="0.5"
android:textColor="@color/white"
android:text="我和我的祖国"
android:layout_centerInParent="true"
android:layout_width="50dp"
android:layout_height="50dp"/>
</RelativeLayout>
这样就可以显示出来了!!!
所以核心的思路其实是:
要使得两个view之间不存在嵌套,这样的话就可以使得view颜色各显示各自的了