3

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

K.Dᴀᴠɪs
  • 9,945
  • 11
  • 33
  • 43
BlackAndWhite
  • 55
  • 2
  • 9

2 Answers2

2

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"/>
DimDim
  • 371
  • 1
  • 18
2

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

Gk Mohammad Emon
  • 6,084
  • 3
  • 42
  • 42
J. Jefferson
  • 980
  • 8
  • 12
  • i had already created an xml and made it the background for my edit text but i didn't reach to the same as the picture – BlackAndWhite Mar 17 '18 at 22:05
  • Can you edit your question to share your code so that we can see your resource files and what you're trying to accomplish? – J. Jefferson Mar 17 '18 at 22:08