How to change style of a default EditText
You have a few options.
Use Android assets studios Android Holo colors generator to generate the resources, styles and themes you need to add to your app to get the holo look across all devices.
Use holo everywhere library.
Use the PNG for the holo text fields and set them as background images yourself. You can get the images from the Android assets studios holo color generator. You'll have to make a drawable and define the normal, selected and disabled states.
UPDATE 2016-01-07
This answer is now outdated. Android has tinting API and ability to theme on controls directly now. A good reference for how to style or theme any element is a site called materialdoc.
Changing style in default EditText - Android
The orange border is not the "normal Edit text" style, but is a part of a specific theme, which is not present on every device. It was mainly used on old Android versions.
So you should not try to override the default style, it is generally a bad design and can confuse the users.
Changing the look of an EditText widget in android studio
Create an XML file with the name "EditTextStyle.xml" in the drawable folder in your project and write the following code:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="2dp"
android:color="@color/black" />
<solid
android:color="#00FFFFFF"
android:paddingLeft="6dp"
android:paddingTop="6dp" />
<padding
android:bottom="6dp"
android:left="6dp"
android:right="6dp"
android:top="6dp" />
</shape>
Use this xml as property of background in edit text like android:background="@drawable/EditTextStyle" in your layout file. Like this
<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_row="1"
android:background="@drawable/EditTextStyle"
android:ems="10"
android:inputType="textUserName" />
It will work for you.
How to change the default EditText text size
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
How to set default edittext color in android 4.x
I answer this by myself. I found a similar question.
Android set edit text style globally in theme doesn't work
It told that I should use like this
<item name="editTextColor">#ff0000</item>
instead of
<item name="android:editTextColor">#ff0000</item>.
I used it because Android Studio auto complete function recommended it.
And now I know that I have to use these BOTH!
Android 5.0 and 6.0 follow the color name="android:editTextColor", but Android 4.X follow the color name="editTextColor".
The problem has solved!
Android EditText default style
//You can try this one it works for me
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#00000000" />
<stroke android:width="2.5dp"
android:color="#FFFFFF" />
<corners
android:radius="5dp"/>
</shape>
Then use this shape for the edit text widget inside an activity xml file as required:
<EditText
android:id="@+id/searchBox"
android:layout_width="fill_parent"
android:layout_height="45dp"
android:background="@drawable/textinputborder"
android:hint="@string/Search"
android:paddingLeft="10dp"
android:inputType="textVisiblePassword" >
</EditText>
How to change the default disabled EditText's style?
In the color file define your color:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:color="@color/disabled_color" />
<item android:color="@color/normal_color"/>
</selector>
In the layout:
<EditText
android:text="whatever text you want"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@drawable/example" />
</EditText>
Set a consistent style to all EditText (for e.g.)
Override the attribute pointing to the EditText
style(named editTextStyle
:) ) in your custom theme:
<style name="App_Theme" parent="@android:style/Theme.Holo">
<item name="android:editTextStyle">@style/App_EditTextStyle</item>
</style>
and make your custom style to extend Widget.EditText
:
<style name="App_EditTextStyle" parent="@android:style/Widget.EditText">
<item name="android:background">@drawable/filled_roundededges_box_dark</item>
<item name="android:textColor">#808080</item>
<item name="android:layout_height">45dip</item>
</style>
Edit:
If you're using the much newer AppCompat related themes use the editTextStyle attribute without the android prefix:
<style name="App_Theme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="editTextStyle">@style/App_EditTextStyle</item>
</style>
Related Topics
Exporting SQLite Database to CSV File in Android
Bring Application to Front After User Clicks on Home Button
Proguard with Ormlite on Android
Change Background Color of Android Menu
Android, Move Bitmap Along a Path
Value of a Global Variable Is Reset After It Is Initialised in Valueeventlistener
First Letter Capitalization for Edittext
React-Native, Android, Genymotion: Adb Server Didn't Ack
Cordova 3.5.0 Install Error- Please Install Android Target 19
How Can Write Code to Make Sharedpreferences for Array in Android
Rotate an Yuv Byte Array on Android
Continuous Speech Recognition Android
Android Volley Self Signed Https Trust Anchor for Certification Path Not Found