Below i have added EditText
style in theme. I have added width and height also. So i removed android:layout_width
and android:layout_height
from my edittext
view. But it is saying error. If i add width and height it is working fine. What is the difference. Is theme is not applying to my edittext view?
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="android:editTextStyle">@style/custom_EditTextStyle</item>
</style>
<style name="custom_EditTextStyle" parent="@android:style/Widget.EditText">
<item name="android:background">@drawable/edittextbox</item>
<item name="android:singleLine">true</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">48dp</item>
</style>
My editText view
<EditText android:hint="Username" />
Your styles.xml
must contain
<resources xmlns:android="http://schemas.android.com/apk/res/android">
at the top.
If this file was auto-generated or you made this file yourself, this attribute is sometimes forgotten.
You need to apply the style to the EditText
:
<EditText android:hint="Username"
style="@style/custom_EditTextStyle" />
Edit: based on your comment I think this is what you want:
<EditText android:hint="Username"
android:layout_height="48dp"
android:layout_width="match_parent"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With