我想做的是在相对布局上带有渐变和灰色底边框,我在应用程序中使用以下自定义视图:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list_item_container"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/list_item_image"
android:layout_width="match_parent"
android:layout_height="@dimen/SIZE_LIST_ITEM_LARGE"
android:scaleType="centerCrop"/>
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/shape_list_item_gradient" />
<com.rahil.widgets.CustomTextView
android:id="@+id/list_item_title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:gravity="bottom"
android:textColor="@color/COLOR_BLACK"/>
</RelativeLayout>
这是shape_list_item_gradient:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<gradient
android:startColor="#FFFFFFFF"
android:endColor="#00FFFFFF"
android:angle="90" />
</shape>
</item>
<item android:bottom="2dp">
<shape android:shape="rectangle">
<stroke android:width="2dp" android:color="@color/COLOR_GRAY" />
</shape>
</item>
</layer-list>
但是上面的代码将边框应用于所有边框,而不仅仅是底部边框。 我将单独的形状xml添加到relativelayout中,但是它不起作用,我认为带有渐变的视图可能覆盖了它? 我安静地迷路了。 谢谢你的帮助。