Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding elevation to layout [closed]

I have a custom listView and the list item that i am using is a linear layout with couple of images and text. Now i want to make this list item a bit elevated just like the pic below

enter image description here

like image 602
Usman Riaz Avatar asked Jun 23 '26 15:06

Usman Riaz


1 Answers

For the background of each list item, you can use an xml drawable to achieve this effect:

mydrawable.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="@color/border_shadow"/>
            <corners android:radius="3dp" />
        </shape>
    </item>

    <item
        android:left="1dp"
        android:right="1dp"
        android:top="1dp"
        android:bottom="3dp">
        <shape android:shape="rectangle">
            <solid android:color="@color/white"/>
            <corners android:radius="3dp" />
        </shape>
    </item>
</layer-list>

To adjust the shadow sizes, tweak the left, right, etc. in the second item. Use it in your LinearLayout for each item as android:background="@drawable/mydrawable".

like image 185
Matter Cat Avatar answered Jun 26 '26 05:06

Matter Cat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!