Android Button、TabLayout的英文字是大写的?
参考
我的Android进阶之旅------>android Button上面的英文字符串自动大写的问题解决
android在使用过程中,解决 Button 和 TabLayout 英文自动大写的问题
如图
1、未解决前的,button内英文文字是大写的,而textview正常解决
1、第一个联想到的就是button控件的大小写属性,可是在button里我没设置啊?奇怪。。。那就找找看哪里出了问题
1.1、layout中的button,用的style=btn_normal_style
<Button android:id="@+id/btn_show_dialog" style="@style/btn_normal_style" android:text="弹出Dialog" />
1.2、btn_normal_style 没有关于大小写的。。继续btn_base_style
<!-- button style --> <style name="btn_normal_style" parent="@style/btn_base_style"> <item name="android:textColor">@color/wx_text_white</item> <item name="android:textSize">@dimen/normal_text_size</item> <item name="android:layout_width">match_parent</item> <item name="android:layout_height">wrap_content</item> </style>
1.3、btn_base_style 也没有大小写的。。。只能前往系统api的style看了
<style name="btn_base_style" parent="Base.TextAppearance.AppCompat.Widget.Button"> <item name="android:textColor">@color/wx_text_white</item> <item name="android:textSize">@dimen/normal_text_size</item> </style>
1.4、这个是一层层追溯到系统的button style最后的。黄天不负有心人,终于找到:
<style name="Base.TextAppearance.AppCompat.Button"> <item name="android:textSize">@dimen/abc_text_size_button_material</item> <item name="android:textAllCaps">true</item> <item name="android:textColor">?android:textColorPrimary</item> </style>
2、问题解决方案
2.1、直接在button的style中添加textAllCaps=false
<style name="btn_base_style" parent="Base.TextAppearance.AppCompat.Widget.Button"> ... <!-- 5.0 sdk material button default textAllCaps=true --> <item name="textAllCaps">false</item> </style>
2.2、上面只针对继承了btn_base_style的button有效,如果想一劳永逸,那么直接修改theme的值
工程使用theme是自定义的AppTheme,且其他activity一般不单独使用theme,那么就会默认使用application的theme
<application ... android:theme="@style/AppTheme"> ... </application>
然后在AppTheme中添加textAllCaps=false
<!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> ... <!-- 5.0 sdk material button default textAllCaps=true --> <item name="textAllCaps">false</item> </style>
其他
最后说一句,其实你button没有style,但是application有theme的话,那么按照theme一层层找下去,也能找到button用的style或者textview用的style,比方说:
好长,还能继续往下,反正就是这个意思。。。
<style name="Platform.AppCompat.Light" parent="android:Theme.Holo.Light"> <item name="android:windowNoTitle">true</item> <item name="android:windowActionBar">false</item> <item name="android:buttonBarStyle">?attr/buttonBarStyle</item> <item name="android:buttonBarButtonStyle">?attr/buttonBarButtonStyle</item> <item name="android:borderlessButtonStyle">?attr/borderlessButtonStyle</item> <!-- Window colors --> <item name="android:colorForeground">@color/foreground_material_light</item> <item name="android:colorForegroundInverse">@color/foreground_material_dark</item> <item name="android:colorBackground">@color/background_material_light</item> <item name="android:colorBackgroundCacheHint">@color/abc_background_cache_hint_selector_material_light</item> <item name="android:disabledAlpha">@dimen/abc_disabled_alpha_material_light</item> <item name="android:backgroundDimAmount">0.6</item> <item name="android:windowBackground">@color/background_material_light</item> <!-- Text colors --> <item name="android:textColorPrimary">@color/abc_primary_text_material_light</item> <item name="android:textColorPrimaryInverse">@color/abc_primary_text_material_dark</item> <item name="android:textColorSecondary">@color/abc_secondary_text_material_light</item> <item name="android:textColorSecondaryInverse">@color/abc_secondary_text_material_dark</item> <item name="android:textColorTertiary">@color/abc_secondary_text_material_light</item> <item name="android:textColorTertiaryInverse">@color/abc_secondary_text_material_dark</item> <item name="android:textColorPrimaryDisableOnly">@color/abc_primary_text_disable_only_material_light</item> <item name="android:textColorPrimaryInverseDisableOnly">@color/abc_primary_text_disable_only_material_dark</item> <item name="android:textColorHint">@color/abc_hint_foreground_material_light</item> <item name="android:textColorHintInverse">@color/abc_hint_foreground_material_dark</item> <item name="android:textColorHighlight">@color/highlighted_text_material_light</item> <item name="android:textColorHighlightInverse">@color/highlighted_text_material_dark</item> <item name="android:textColorLink">?attr/colorAccent</item> <item name="android:textColorLinkInverse">?attr/colorAccent</item> <item name="android:textColorAlertDialogListItem">@color/abc_primary_text_material_light</item> <!-- Text styles --> <item name="android:textAppearance">@style/TextAppearance.AppCompat</item> <item name="android:textAppearanceInverse">@style/TextAppearance.AppCompat.Inverse</item> <item name="android:textAppearanceLarge">@style/TextAppearance.AppCompat.Large</item> <item name="android:textAppearanceLargeInverse">@style/TextAppearance.AppCompat.Large.Inverse</item> <item name="android:textAppearanceMedium">@style/TextAppearance.AppCompat.Medium</item> <item name="android:textAppearanceMediumInverse">@style/TextAppearance.AppCompat.Medium.Inverse</item> <item name="android:textAppearanceSmall">@style/TextAppearance.AppCompat.Small</item> <item name="android:textAppearanceSmallInverse">@style/TextAppearance.AppCompat.Small.Inverse</item> <item name="android:listChoiceIndicatorSingle">@drawable/abc_btn_radio_material</item> <item name="android:listChoiceIndicatorMultiple">@drawable/abc_btn_check_material</item> <item name="android:listPreferredItemPaddingLeft">@dimen/abc_list_item_padding_horizontal_material</item> <item name="android:listPreferredItemPaddingRight">@dimen/abc_list_item_padding_horizontal_material</item> <item name="android:actionModeCutDrawable">?actionModeCutDrawable</item> <item name="android:actionModeCopyDrawable">?actionModeCopyDrawable</item> <item name="android:actionModePasteDrawable">?actionModePasteDrawable</item> <item name="android:actionModeSelectAllDrawable">?actionModeSelectAllDrawable</item> <item name="android:textSelectHandle">@drawable/abc_text_select_handle_middle_mtrl_light</item> <item name="android:textSelectHandleLeft">@drawable/abc_text_select_handle_left_mtrl_light</item> <item name="android:textSelectHandleRight">@drawable/abc_text_select_handle_right_mtrl_light</item> </style>
TabLayout解决方案
app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"
最后
总结:小问题,也需要折腾下!
低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
Flutter误删除android/ios目录怎么办?
最近有朋友遇到了这样的一个问题:在Flutter开发中误删android/ios该如何挽救?。很多朋友会尝试从回收站中恢复,但如果无法从回收站中恢复怎么办?还有办法拯救一下自己吗。答案是肯定的。我们可以通过flutter create命令拯救自己。看一下flutter create: flutter help create Create a new Flutter project. If run on a project that already exists, this will repair the project, recreating any files that are missing. Usage: flutter create <output directory> -h, --help Print this usage information. --[no-]pub Whether to run "flutter packages get" after the project has been created. (defaults to on) --[no-]...
- 下一篇
Android 多进程之Messenger的使用
Android多进程系列 Android 多进程通信之几个基本问题 Android多进程之Binder的使用 Android多进程之手动编写Binder类 Android多进程之Binder解绑监听的问题 Android多进程之Binder的意外死亡及权限校验 Messenger也可以作为Android多进程的一种通信方式,通过构建Message来在客户端和服务端之间传递数据 简单使用Messenger 客户端通过Messenger向服务端进程发送消息 构建一个运行在独立进程中的服务端Service: public class MessengerService extends Service { private static final String TAG = "MessagerService"; /** * 处理来自客户端的消息,并用于构建Messenger */ private static class MessengerHandler extends Handler { @Override public void handleMessage(Message message) {...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- Docker安装Oracle12C,快速搭建Oracle学习环境
- Windows10,CentOS7,CentOS8安装MongoDB4.0.16
- CentOS8编译安装MySQL8.0.19
- MySQL8.0.19开启GTID主从同步CentOS8
- CentOS8安装Docker,最新的服务器搭配容器使用
- CentOS8,CentOS7,CentOS6编译安装Redis5.0.7
- SpringBoot2整合Redis,开启缓存,提高访问速度
- CentOS7,8上快速安装Gitea,搭建Git服务器
- Docker使用Oracle官方镜像安装(12C,18C,19C)
- CentOS关闭SELinux安全模块