I apply elevation attribute and a drawable background which supply a rounded outline to the EditText View
, but there is no shadow as expected.
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:background="#FAFAFA"
tools:context=".MainActivity">
<EditText
android:id="@+id/editText"
android:layout_width="0dp"
android:layout_height="51dp"
android:layout_marginTop="52dp"
android:elevation="20dp"
android:background="@drawable/rounded_edittext"
android:drawableStart="@drawable/ic_search_icon"
android:drawableLeft="@drawable/ic_search_icon"
android:ems="10"
android:inputType="textPersonName"
android:paddingLeft="20dp"
android:paddingRight="20dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView" />
</android.support.constraint.ConstraintLayout>
And the background rounded_edittext.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FFFFFF"/>
<corners
android:bottomRightRadius="27.5dp"
android:bottomLeftRadius="27.5dp"
android:topLeftRadius="27.5dp"
android:topRightRadius="27.5dp"/>
<stroke android:color="#66000000" android:width="0.5dp"/>
</shape>
UPDATE
Below is the original design.
border color #000000 opacity 10(0~100)
shadow color #000000 opacity 5(0~100)