Android : How To Change The Style Of Edit Text?
Solution 1:
You can use the attribute style="@style/your_style"
that is defined for any widget.
To define your style you have to create a file called style.xml
in the values folder (i.e. \res\values\styles.xml
) and use the following syntax:
<stylename="You.EditText.Style"parent="@android:style/Widget.EditText"><itemname="android:textColor">@color/your_color</item><itemname="android:gravity">center</item></style>
The attribute parent="@android:style/Widget.EditText"
is important because it will ensure that the style being defined extends the basic Android EditText
style, thus only properties different from the default style need to be defined.
Solution 2:
<stylename="AppTheme"parent="Theme.AppCompat.Light.DarkActionBar"><itemname="colorPrimaryDark">@color/colorPrimaryDark</item><itemname="colorPrimary">@color/colorPrimary</item><itemname="android:colorBackground">@color/windowBackground</item><itemname="android:textColor">@color/textColor</item><itemname="colorAccent">@color/colorAccent</item>
//apply Button style
<itemname="android:editTextStyle">@style/editTextStyle</item></style>
//Button Style
<stylename="editTextStyle"parent="@style/Widget.AppCompat.EditText"><itemname="android:textColor">@color/colorWhite</item><itemname="android:background">@color/colorPrimary</item><itemname="android:textSize">24sp</item><itemname="android:paddingTop">10dp</item><itemname="android:paddingBottom">10dp</item></style>
Solution 3:
Yes, it is definitely possible. See http://developer.android.com/guide/topics/ui/themes.html (Raghu already postet that link) for more details.
You can also but a background in it, see this post: http://www.anddev.org/tutorial_buttons_with_niceley_stretched_background-t4369.html It only covers buttons, but it is exactly the same for edittexts.
Post a Comment for "Android : How To Change The Style Of Edit Text?"