BlackAndWhite
BlackAndWhite

Reputation: 55

How to add a blurred shadow to an edit text?

I want to add a blurred shadow for my edit text but I don't know how? I had made the shape but I don't know the attribute for adding blur to the edit text. I made a drawable resource file and make this as a background to my edit text but it doesn't look as the picture and this my code.

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <!-- "shadow" -->
    <item >
        <shape android:shape="rectangle" >
            <solid android:color="#E8E9ED"
                />

            <corners android:radius="20dp" />
        </shape>
    </item>


    <item android:bottom="5px"
        android:left="5px"
        android:right="5px"
        android:top="5px">
        <shape android:shape="rectangle">
            <solid android:color="#FFFFFF"/>
            <corners android:radius="20dp" />
        </shape>
    </item>

</layer-list>

enter image description here

Upvotes: 3

Views: 4944

Answers (2)

J. Jefferson
J. Jefferson

Reputation: 1020

The attributes: android:shadowColor, android:shadowRadius, android:shadowDx, and android:shadowDy create text shadow. If want to create a shadow behind your edittext box, you have to create a custom XML view in your res/drawable folder. Then set the attribute android:background="@drawable/customFileName" in your main.xml inside the edittext block. Here is a link to an answer to help you get started: Add drop shadow effects to EditText Field

Upvotes: 2

DimDim
DimDim

Reputation: 381

You can do this in xml :

<EditText android:id="@+id/shadowed_text_field" 
        android:layout_height="50dp"
        android:layout_width="200dp" 
        android:gravity="center_horizontal" 

        android:shadowColor="@color/#99a7b3c6"
        android:shadowDx="1.2"
        android:shadowDy="1.2"
        android:shadowRadius="1.5" 

        android:background="@color/white"/>

Upvotes: 2

Related Questions