我的Android进阶之旅------>android Button上面的英文字符串自己主动大写的问题解决
今天碰到一个关于Button的问题:android Button上面的英文字符串会自己主动变成大写,执行的Android 5.1版本号,例如以下图所看到的:
图1:Button
图2:TextView
这个Button的定义代码例如以下
<Button
android:id="@+id/addContacts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/contactList_addContact" />
TextView的定义代码例如以下
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="10dp"
android:layout_weight="1"
android:gravity="center"
android:text="@string/contactList_addContact"
android:textSize="24sp" />
引用同一个字符串contactList_addContact。字符串内容例如以下:
<string name="contactList_addContact">Add</string>
可是Button显示出来就是ADD。而TextView显示出来就是Add。之前还真的没遇到过。郁闷。并且其它的Button都是显示正常,例如以下所看到的:
这两个按钮定义代码例如以下:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_margin="10dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal" > <Button
android:id="@+id/btn_cancel"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/btn_cancel"
android:textColor="@color/black" /> <Button
android:id="@+id/btn_save"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/btn_save"
android:textColor="@color/black" />
</LinearLayout>
所引用的字符串为:
<string name="btn_cancel">Cancel</string>
<string name="btn_save">Save</string>
好吧。以上就是问题的内容。至于为什么会有这个问题我预计是Android 5.1的SDK把Button的默认Style改了,样式默认把textAllCaps设置为true了,也没有去细致研究。查看系统选代码:frameworks/base/core/res/res/values/styles_material.xml的第233行,代码例如以下:
<style name="TextAppearance.Material.Button">
<item name="textSize">@dimen/text_size_button_material</item>
<item name="fontFamily">@string/font_family_button_material</item>
<item name="textAllCaps">true</item>
<item name="textColor">?
attr/textColorPrimary</item>
</style>
能够发现真的是把textAllCaps属性设置为true了。
以下来说说怎么解决问题。
仅仅须要在Add按钮的定义中加上一个 android:textAllCaps="false"属性就可以,该属性是用来设置是否使用大写字母来呈现文本。
即把代码改成例如以下:
<Button
android:id="@+id/addContacts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAllCaps="false"
android:text="@string/contactList_addContact" />
好吧,这样就攻克了,改完后的效果图例如以下:
====================================================================================
作者:欧阳鹏 欢迎转载,与人分享是进步的源泉!
转载请保留原文地址:http://blog.csdn.net/ouyang_peng
====================================================================================
我的Android进阶之旅------>android Button上面的英文字符串自己主动大写的问题解决的更多相关文章
- 我的Android进阶之旅------>android Button上面的英文字符串自动大写的问题解决
今天碰到一个关于Button的问题:android Button上面的英文字符串会自动变成大写,运行的Android 5.1版本,如下图所示: 图1:Button 图2:TextView 这个Butt ...
- android Button上面的英文字符串自动大写的问题解决
xml文件中加入: android:textAllCaps="false"
- 我的Android进阶之旅------>关于android:layout_weight属性的详细解析
关于androidlayout_weight属性的详细解析 效果一 效果二 图3的布局代码 图4的布局代码 效果三 图7代码 图8代码 效果四 效果五 版权声明:本文为[欧阳鹏]原创文章,欢迎转载,转 ...
- 我的Android进阶之旅------>关于android:layout_weight属性的一个面试题
最近碰到一个面试题,按照下图,由Button和EditText组成的界面下厨布局代码,解决这题目需要使用android:layout_weight的知识. 首先分析上图所示的界面可以看成一下3个部分. ...
- 我的Android进阶之旅------> Android在TextView中显示图片方法
面试题:请说出Android SDK支持哪些方式显示富文本信息(不同颜色.大小.并包括图像的文本信息).并简要说明实现方法. 答案:Android SDK支持例如以下显示富文本信息的方式. 1.使用T ...
- 我的Android进阶之旅------>Android字符串资源中的单引號问题error: Apostrophe not preceded by 的解决的方法
刚刚在string字符串资源文件里,写了一个单引號.报错了,错误代码例如以下 error: Apostrophe not preceded by \ (in OuyangPeng's blog ) 资 ...
- 我的Android进阶之旅------> Android为TextView组件中显示的文本加入背景色
通过上一篇文章 我的Android进阶之旅------> Android在TextView中显示图片方法 (地址:http://blog.csdn.net/ouyang_peng/article ...
- 【我的Android进阶之旅】Android 源代码中的Java代码中//$NON-NLS-1$ 注释是什么意思?
1.背景 最近在负责公司基础业务和移动基础设施的开发工作,正在负责Lint代码静态检查工作.因此编写了自定义的Lint规则,在编写自定义的Lint规则前,当然是需要去把Google的关于Lint检测的 ...
- 我的Android进阶之旅------>Android系统设置默认来电铃声、闹钟铃声、通知铃声
首先了解Android系统本身提供的默认铃声文件,这些文件都放在 /system/media/audio 文件夹下. /system/media/audio/ringtones 系统来电铃声 ...
随机推荐
- MongoDB Master-Slave cluster with authentication setup
Master Server create mongo db folder with sub folders like data, conf, && log mkdir -p /opt/ ...
- 在ubuntu中安装Markdown神器Typora
title: 在ubuntu中安装Markdown神器Typora toc: false date: 2018-09-01 17:48:15 categories: methods tags: ubu ...
- JavaScript 面向对象(随笔)
构造函数创建对象 1构造函数是用new创建对象时调用的函数,与普通唯一的区别是构造函数名应该首字母大写. function Person() { this.age = 50; } let a = ne ...
- C# WinForm DataGridView 给标题列增加序号及格式化某个字段
DataGridView 给标题列增加序号 private void dataGridView1_DataBindingComplete(object sender, DataGridViewBind ...
- jQueryDOM操作模块
DOM操作模块 1.复习选择器模块(选择器模块结束) 目的:学而时习之 复习和总结选择器模块 2.DOM的基本操作方法 目标:回顾DOM操作的基本方法 3.1 DOM操作 -创建节点 练习 1:创建1 ...
- (转载)android开发常见编程错误总结
首页 › 安卓开发 › android开发 android开发常见编程错误总结 泡在网上的日子 / 文 发表于2013-09-07 13:07 第771次阅读 android,异常 0 编辑推荐:稀 ...
- 把pcl的VTK显示融合到MFC(代码找原作者)
转自PCL中国,原文链接:http://www.pclcn.org/bbs/forum.php?mod=viewthread&tid=223&extra=page%3D1 本人做了少量 ...
- codevs 2800 送外卖 floyd + Tsp
简单的状压动归 #include<cstdio> #include<algorithm> using namespace std; const int N=17; const ...
- 51nod1072 - 威佐夫游戏【威佐夫博弈】
有2堆石子.A B两个人轮流拿,A先拿.每次可以从一堆中取任意个或从2堆中取相同数量的石子,但不可不取.拿到最后1颗石子的人获胜.假设A B都非常聪明,拿石子的过程中不会出现失误.给出2堆石子的数量, ...
- Git学习笔记(1)
1.安装Git: 在linux下安装:yum install git 其他系统安装在这里略去~~~ 安装完成后,需要设置一下,在命令行输入以下命令: [root@xwq ~]# git config ...