1: xml
android:textStyle="normal"
android:textStyle="bold"
android:textStyle="italic"
正常,加粗,斜体
2:String.xml 配置
Plain, <b>bold</b>, <i>italic</i>, <b><i>bold-italic</i>
3:
获取String 使用getText()不会丢失text的字体样式信息,
getString()则会丢西信息。
另一种方式是, this.getResources.getText()也不会丢失文字样式信息。
// See res/any/layout/resources.xml for this view layout definition.
setContentView(R.layout.resources);
TextView tv;
CharSequence cs;
String str;
// ====== Using the Context.getString() convenience method ===========
// Using the getString() conevenience method, retrieve a string
// resource that hapepns to have style information. Note the use of
// CharSequence instead of String so we don't lose the style info.
cs = getText(R.string.styled_text);
tv = (TextView)findViewById(R.id.styled_text);
tv.setText(cs);
// Use the same resource, but convert it to a string, which causes it
// to lose the style information.
str = getString(R.string.styled_text);
tv = (TextView)findViewById(R.id.plain_text);
tv.setText(str);
// ====== Using the Resources object =================================
// You might need to do this if your code is not in an activity.
// For example View has a protected mContext field you can use.
// In this case it's just 'this' since Activity is a context.
Context context = this;
// Get the Resources object from our context
Resources res = context.getResources();
// Get the string resource, like above.
cs = res.getText(R.string.styled_text);
tv = (TextView)findViewById(R.id.res1);
tv.setText(cs);
// Note that the Resources class has methods like getColor(),
// getDimen(), getDrawable() because themes are stored in resources.
// You can use them, but you might want to take a look at the view
// examples to see how to make custom widgets.
分享到:
相关推荐
高德地图自定义地图apidemo,地图样式,标注样式,自定义窗体
android ApiDemo android ApiDemo
android apidemo.apk
android sdk中拿出来的 android api demo,sdk\samples\android-17,给需要的人
关于apidemo的例子,里面的例子非常的不错啊
Google官方API(Android ApiDemo) 打包下载,初学者学习的捷径
android apidemo android apidemo android apidemo
Android官方apidemo,android studio直接导入,运行安装即可
android APIdemo 深入分析
android中文apidemo详解事例,适合新手阅读快速上手。
在SpringBoot中应用swagger2的一个DEMO,主要功能包括:WEB访问API...项目中有中文字体文件,使用的时候先删除目录docs、html和pdf目录,启动项目,然后点击idea maven的test lifecycle。可方便的移植到自己的项目中。
腾讯微博APIDemo aip sdk
android 示例源码 apidemo 内容很全的,直接导入即可使用学习
最新6.0,最新APIDEMO
百度地图API使用,及Demo。一套应用程序接口,帮助开发者构建功能丰富、交互性强的地图应用程序。 JavaScript API Mobile API Web Services Flash API 导航控件 缩略图控件 地图类型控件 比例尺控件 ...
把Android Apidemo第一个例子抽出来,以后每学一节就加进Apidemo框架里,加深理解
Android2.3ApiDemo
android 高德 地图apiDemo