如何更改默认的EditText文本大小(How to change the default EditText text size)
我试图更改默认的EditText样式,我使用TextView样式通过以下方式完成:
<style name="MyTextViewStyle" parent="android:Widget.TextView"> <item name="android:textColor">@color/pink</item> <item name="android:textSize">@dimen/textSize</item> </style>并将其用作android:textViewStyle样式
<style name="AppBaseTheme" parent="Theme.AppCompat.Light"> <item name="android:textViewStyle">@style/MyTextViewStyle</item> </style>如何使用EditText实现相同的功能?
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 ?
最满意答案
您只需在项目中使用此代码,就可以在整个项目中获得所需的Edittext样式...
<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>并在Mainfest文件中添加此行
<application android:theme="@style/MyAppTheme" > ... </application>祝一切顺利
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
更多推荐
发布评论