我遇到的情况是:在shape中设置corners与solid后只有soild的颜色正常显示,corners未显示成圆角。
原因:错误不在shape,而是布局中background设置,上层控件的background覆盖下层控件background(设置shape
的控件)而导致的圆角被遮盖的问题。
布局代码:
<LinearLayout
<span style="white-space:pre"> </span>android:background="@drawable/dailog_update"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
>
<TextView
<span style="white-space:pre"> </span> android:background="#c2c2c2"
android:id="@+id/dialog_update_title_tv"
android:textColor="#ffffff"
android:textSize="18dp"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:gravity="center"
android:text="版本更新" />
</linearLayout>
dialog_update shape代码:
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<corners android:radius="5dip" />
<solid android:color="#ff66ccff"/>
</shape>
由shape可以看出布局中设置background后的linearlayout的显示形状应该为:
而textview设置background后的形状为:
而textview又显示在linearlayout的上层所以导致其圆角被遮盖。
谢谢。