2

I am trying to change the default EditText style, I have done it with the TextView style the following way:

<style name="MyTextViewStyle" parent="android:Widget.TextView">
    <item name="android:textColor">@color/pink</item>
    <item name="android:textSize">@dimen/textSize</item>
</style>

And using it as the android:textViewStyle style

<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
    <item name="android:textViewStyle">@style/MyTextViewStyle</item>
</style>

How can I achieve the same with an EditText ?

user1940676
  • 4,348
  • 9
  • 44
  • 73

5 Answers5

5

You just use this code in your Project you can get the required Edittext style throughout your project...

<style name="MyAppTheme" parent="android:Theme.Light">
<item name="android:editTextStyle">@style/CustomEditTextStyle</item>
</style>

<style name="CustomEditTextStyle">
<item name="android:background">@drawable/edittxt_shape</item>
<item name="android:clickable">true</item>
<item name="android:enabled">true</item>
<item name="android:focusable">true</item>
<item name="android:focusableInTouchMode">true</item>
<item name="android:gravity">center_vertical</item>
</style> 

and add this line in your Mainfest file

<application
android:theme="@style/MyAppTheme" >
...
</application>

All the best

Naveen Kumar Kuppan
  • 1,424
  • 1
  • 10
  • 12
1

this site may helps you try this

http://android-holo-colors.com/

MilapTank
  • 9,988
  • 7
  • 38
  • 53
0

edittext_style.xml

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

<item android:state_focused="true"><shape>
        <solid android:color="@android:color/white" />

        <stroke android:width="1dp" android:color="#26ADE4" />

        <padding android:bottom="5dp" android:left="5dp" android:right="5dp" android:top="5dp" />
    </shape></item>
<item android:state_pressed="true"><shape>
        <solid android:color="@android:color/white" />

        <stroke android:width="1dp" android:color="#26ADE4" />

        <padding android:bottom="5dp" android:left="5dp" android:right="5dp" android:top="5dp" />
    </shape></item>
<item><shape>
        <solid android:color="@android:color/white" />

        <stroke android:width="1dp" android:color="#26ADE4" />

        <padding android:bottom="5dp" android:left="5dp" android:right="5dp" android:top="5dp" />
    </shape></item>

check this custom style

use the following attribute to apply this to your editText

android:background="@drawable/edittext_style"

I hope this would help you

Akbarsha
  • 2,422
  • 23
  • 34
0

You can custom style by adding this property of EditTest:

  <EditText
            android:id="@+id/EditText1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="@dimen/textSize"
            android:textColor="@color/pink" />
Himanshu Agarwal
  • 4,623
  • 5
  • 35
  • 49
0

create a style like below

<style name="editTextStyle" parent="@android:style/Widget.EditText">
    <item name="android:layout_width">match_parent</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:textColor">#000</item>
    <item name="android:textSize">18sp</item>
</style>

and apply it in your Editext view like

<EditText
        android:id="@+id/EditText1"
        style="@style/editTextStyle"/>
maddy d
  • 1,530
  • 2
  • 12
  • 23