Jan 31, 2014

Add shadow to EditText

To add shadow to EditText, simple add the following to XML inside <EditText>:

        android:shadowColor="#000000"
        android:shadowDx="5.0"
        android:shadowDy="5.0"
        android:shadowRadius="5.0" 


Example to shadow effect to EditText in the example "Implement TextWatcher to EditText".

EditText with shadow
EditText with shadow
Example:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="android-coding.blogspot.com" />

    <EditText
        android:id="@+id/input"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"

        android:shadowColor="#000000"
        android:shadowDx="5.0"
        android:shadowDy="5.0"
        android:shadowRadius="5.0" 

        android:textSize="28sp" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textStyle="italic"
        android:text="afterTextChanged(Editable s)" />
    <TextView
        android:id="@+id/promptAfter"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textStyle="bold" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textStyle="italic"
        android:text="beforeTextChanged(CharSequence s, int start, int count, int after)" />
    <TextView
        android:id="@+id/promptBefore"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textStyle="bold" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textStyle="italic"
        android:text="onTextChanged(CharSequence s, int start, int before, int count)" />
    <TextView
        android:id="@+id/promptOn"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textStyle="bold" />
 
</LinearLayout>

No comments:

Post a Comment

Infolinks In Text Ads