0

I am trying shadow text view like this: enter image description here

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:gravity="top|center"
    android:background="@drawable/gradient">
        <TextView
            android:layout_width="300dp"
            android:layout_height="50dp"
            android:text="@string/ph"
            style="@style/TextBox"
            android:textSize="16sp"/>
 </LinearLayout>

gradient.xml

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"  >
<item>
    <shape android:shape="rectangle">
        <gradient
            android:endColor="#FFFFFF"
            android:startColor="#FFFFFF"
            android:type="linear"
            android:centerColor="#E3F2FD"
            android:angle="90">
        </gradient>

    </shape>
</item>

This code can't get my design. Is it possible to textview like my picture?

RPichioli
  • 3,245
  • 2
  • 25
  • 29
RamChithra
  • 57
  • 2
  • 10

2 Answers2

0

Here i tried to create same shadow as your requirement which will look like this. I know the shadow color is not blur as u want

enter image description here

<LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:background="@drawable/shadow"
        android:orientation="vertical"
        android:paddingBottom="5dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/rectangle_shape"
            android:padding="10dp"
            android:text="Phone Number" />
    </LinearLayout>

drawable/shadow.xml

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="#220000ff" />
    <corners android:radius="20dp" />
</shape>

drawable/rectangle_shape.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:radius="20dp" />
</shape>
Divyang Panchal
  • 1,889
  • 1
  • 19
  • 27
0

make xml backround_with_shadow and paste this code-

<?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="#87ceeb" />
                <corners android:radius="5dp"/>
            </shape>
        </item>
and set xml as background of layout
        <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>
Aryan Dhankar
  • 179
  • 1
  • 10