如何更改默认的EditText文本大小(How to change the default EditText text size)

编程入门 行业动态 更新时间:2024-10-18 06:09:39
如何更改默认的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

更多推荐

本文发布于:2023-08-04 09:29:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1415259.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何更改   文本   大小   EditText   size

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!