As far as my knowledge aids me, there isn't any property to drop shadow around an EditText field, that can be set in the layout file. I searched for the problem and found solution that I've to provide a custom background xml drawable.
My drawable/background_with_shadow looks like this:
<?xml version="1.0" encoding="utf-8"?>
<layer-lis xmlns:android="http://schemas.android.com/apk/res/android">
<item >
<shape
android:shape="rectangle">
<solid android:color="@android:color/darker_gray" />
<corners android:radius="5dp"/>
</shape>
</item>
<item android:right="1dp" android:left="1dp" android:bottom="2dp">
<shape
android:shape="rectangle">
<solid android:color="@android:color/white"/>
<corners android:radius="5dp"/>
</shape>
</item>
</layer-list>
and I'm setting this property for my LinearLayout
which contains an EditText
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background_with_shadow">
<EditText>
.
.
</EditText>
<LinearLayout>
However it just drops the shadow around the bottom and bottom corners. How would I do it for all the four sides and corners?
Set this layout as your LinearLayout background.
There are some better ways to get shadow around your edit text without using
layer-list
:#1
Wrap your
EditText
in aCardView
like this :OUTPUT :
2
Use a 9 patch as the background of your
EditText
:OUTPUT
Read more about 9patch here.
Here's a great online tool to generate 9 patch shadow.