First create this background drawable
with a rectangle
, round corner
and a stroke
in grey. Called background_drawable.xml
:
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#ffffff"/>
<corners android:radius="5dp" />
<stroke android:width="1dp"
android:color="#C3C3C3"/>
</shape>
After that you set this as android:background=""
in your LinearLayout
and EditText
, both widgets have android:elevation="2dp"
for it's shadow on each sites matching the stroke
of the rectangle
. Here is your layout called activity_main.xml
:
<LinearLayout
android:layout_width="200dp"
android:layout_height="100dp"
android:elevation="2dp"
android:id="@+id/linear_layout"
android:background="@drawable/background_drawable"
android:layout_centerInParent="true"
android:orientation="horizontal" />
<EditText
android:layout_width="200dp"
android:layout_height="wrap_content"
android:id="@+id/edit_text"
android:elevation="2dp"
android:layout_marginTop="10dp"
android:background="@drawable/background_drawable"
android:layout_below="@+id/linear_layout"
android:layout_centerHorizontal="true"
android:padding="10dp"/>
The final result will look like this image.