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 s
There are some better ways to get shadow around your edit text without using layer-list
:
#1
Wrap your EditText
in a CardView
like this :
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="7dp"
android:layout_margin="10dp"
app:cardCornerRadius="0dp">
<EditText
android:id="@+id/msg_box"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:hint="Write a message"
android:paddingLeft="5dp"
android:paddingStart="5dp"
android:textColorHint="#c7c7c7"
android:textSize="15dp" />
</android.support.v7.widget.CardView>
OUTPUT :
Use a 9 patch as the background of your EditText
:
<EditText
android:id="@+id/msg_box"
android:padding="20dp"
android:background="@drawable/shadow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:lines="5"
android:gravity="top"
android:hint="Enter your complaint..."
android:textColorHint="#a7a7a7"
android:textSize="15dp" />
OUTPUT
Read more about 9patch here.
Here's a great online tool to generate 9 patch shadow.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<item>
<shape>
<!-- set the shadow color here -->
<stroke
android:width="2.5dp"
android:color="@color/darker_gray" />
<!-- setting the thickness of shadow (positive value will give shadow on that side) -->
<!--Set shadow width as per your requirement -->
<padding
android:bottom="2dp"
android:left="0.5dp"
android:right="2dp"
android:top="0.5dp" />
<corners android:radius="2dp" />
</shape>
</item>
<!--White Background -->
<item>
<shape>
<solid android:color="#fff" />
<corners android:radius="2dp" />
</shape>
</item>
</layer-list>
Set this layout as your LinearLayout background.