Skip to content Skip to sidebar Skip to footer

Adding Shadow On The Bottom Of List Item Of Listview

I want to add shadow to bottom of my ListView item !! I tried paddingEdageLenght but no change happened ! I added circular edges but i can't add the shadow below the item this is

Solution 1:

In list_view_item, add a dummy View after your RelativeLayout and wrap them all at vertical LinearLayout like this:

<LinearLayoutandroid:orientation="vertical"><RelativeLayout>
        ...
        ...
    </RelativeLayout><Viewandroid:id="@+id/shadow"android:layout_width="fill_parent"android:layout_height="3dp" <!--oryourneededheightvalue-->
        android:background="@drawable/shadow_drawable">     
    </View></LinearLayout>

and at drawable folder add the new shadow_drawable.xml and put this at it

<?xml version="1.0" encoding="utf-8"?><shapexmlns:android=”http://schemas.android.com/apk/res/android”><gradientandroid:startColor="@color/#000000" <!--black-->
        android:endColor="@color/#FFFFFF" <!--white-->
        android:angle="90" <!-- angle of the gradient-->
        >
    </gradient></shape>

Solution 2:

you have to add footerview in listview,

how to add footerview check bellow code,

private View footerView;
footerView = ((LayoutInflater)getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.listview_footer, null, false);
ListView.addFooterView(footerView);

so, what ever you can do, in footer view.

Solution 3:

You can make 9-patch image for border with shadow effect.

Create a new drawable resource file named "border.xml" in "res/drawable" and write the following code-

<?xml version="1.0" encoding="utf-8"?><layer-listxmlns:android="http://schemas.android.com/apk/res/android"><item ><shapeandroid:shape="rectangle"><gradientandroid:startColor="#ddd"android:endColor="#555"android:type="linear" /><cornersandroid:radius="0dp"/></shape></item><itemandroid:right=".5dp"android:left=".5dp"android:bottom="2dp"android:top=".5dp"><shapeandroid:shape="rectangle"><solidandroid:color="@android:color/white"/><cornersandroid:radius="0dp"/></shape></item></layer-list>

Just put android:background="@drawable/border" where you want to apply border.

You can change in android:right,android:left,android:top and android:bottom to give size to border. you can also make change in android:shape for more effect.

Hope its help for you !

Post a Comment for "Adding Shadow On The Bottom Of List Item Of Listview"