samedi 16 mai 2015

Android border bottom for custom view not working

What I'm trying to do is to have a relativelayout with a gradient on it and a gray bottom border, I'm using the below custom view in my application:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
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>

and this is shape_list_item_gradient:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://ift.tt/nIICcg">
<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>

but the above code applies border to all borders not just bottom border. I added the separate shape xml to the relativelayout but it didn't work which I assume the view with gradient covers it maybe?? I'm quiet lost. thanks for your help.

Aucun commentaire:

Enregistrer un commentaire