- 浏览: 62782 次
- 性别:
- 来自: 沈阳
文章分类
最新评论
Android提供三种字体:“Sans”,“serif“和“monospace”。 默认:Sans
1、在Android XML文件中设置字体
<TextView
android:id="@+id/t1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello_world!您好,世界!(sans)"
android:typeface="sans" />
<TextView
android:id="@+id/t2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello_world!您好,世界!(serif)"
android:typeface="serif" />
<TextView
android:id="@+id/t3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello_world!您好,世界!(monospace)"
android:typeface="monospace" />
2、自定义字体
1)将新字体的TTF文件copy到assets/fonts/目录下面。
2)我们需要将widget设置为该字体,比较遗憾的是,不能直接在XML文件中进行,需要编写源代码。
typeface= Typeface.createFromAsset(getAssets(), "fonts/lz.ttf");
textView.setTypeface(typeface);
3. UI所有组件使用自定义字体
3.1 方法
public static void changeFonts(ViewGroup root, Activity act) {
Typeface tf = Typeface.createFromAsset(act.getAssets(),
"fonts/lz.ttf");
for (int i = 0; i < root.getChildCount(); i++) {
View v = root.getChildAt(i);
if (v instanceof TextView) {
((TextView) v).setTypeface(tf);
} else if (v instanceof Button) {
((Button) v).setTypeface(tf);
} else if (v instanceof EditText) {
((EditText) v).setTypeface(tf);
} else if (v instanceof ViewGroup) {
changeFonts((ViewGroup) v, act);
}
}
}
}
3.2 activity中调用方法
ViewGroup viewGroup=(ViewGroup)findViewById(android.R.id.content);
FontManager.changeFonts(viewGroup, this);
4. html的使用
String str = "测试<b>黑体字</b>、<i>斜体字</i>、<u>下划 线</u>、<font color='red'>红色字</font>的显示。" ;
textView.setText(Html.fromHtml(str));
1、在Android XML文件中设置字体
<TextView
android:id="@+id/t1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello_world!您好,世界!(sans)"
android:typeface="sans" />
<TextView
android:id="@+id/t2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello_world!您好,世界!(serif)"
android:typeface="serif" />
<TextView
android:id="@+id/t3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello_world!您好,世界!(monospace)"
android:typeface="monospace" />
2、自定义字体
1)将新字体的TTF文件copy到assets/fonts/目录下面。
2)我们需要将widget设置为该字体,比较遗憾的是,不能直接在XML文件中进行,需要编写源代码。
typeface= Typeface.createFromAsset(getAssets(), "fonts/lz.ttf");
textView.setTypeface(typeface);
3. UI所有组件使用自定义字体
3.1 方法
public static void changeFonts(ViewGroup root, Activity act) {
Typeface tf = Typeface.createFromAsset(act.getAssets(),
"fonts/lz.ttf");
for (int i = 0; i < root.getChildCount(); i++) {
View v = root.getChildAt(i);
if (v instanceof TextView) {
((TextView) v).setTypeface(tf);
} else if (v instanceof Button) {
((Button) v).setTypeface(tf);
} else if (v instanceof EditText) {
((EditText) v).setTypeface(tf);
} else if (v instanceof ViewGroup) {
changeFonts((ViewGroup) v, act);
}
}
}
}
3.2 activity中调用方法
ViewGroup viewGroup=(ViewGroup)findViewById(android.R.id.content);
FontManager.changeFonts(viewGroup, this);
4. html的使用
String str = "测试<b>黑体字</b>、<i>斜体字</i>、<u>下划 线</u>、<font color='red'>红色字</font>的显示。" ;
textView.setText(Html.fromHtml(str));
发表评论
-
android 备用
2014-08-03 13:26 420http://blog.csdn.net/rain_butte ... -
Android中px与dip,sp与dip等的转换工具类(转)
2014-07-16 20:07 571http://www.cnblogs.com/wader201 ... -
mina
2014-07-03 14:12 479http://chwshuang.iteye.com/blog ... -
android获取IMEI
2014-06-17 08:34 504核心代码: Imei = ((TelephonyMan ... -
andorid ui
2014-06-04 22:39 0http://blog.csdn.net/ddddpow/ar ... -
android alarmManage
2014-05-28 21:47 668转自:http://jinguo.iteye.com/bl ... -
adaf
2014-05-27 22:32 0http://www.eoeandroid.com/thr ... -
weixin
2014-05-13 22:42 0android weisixn -
jpajpa
2014-01-28 15:06 484http://www.iteye.com/problems/9 ... -
吉安帕
2014-01-23 22:30 0dfsgdaffgadrgad -
CrudRepository
2013-11-28 19:58 0PagingAndSortingRepository Cr ... -
Android 的第三方报表组件,AChartEngine 案列
2013-08-19 16:48 0http://www.kuaipan.cn/file/id_3 ... -
android sdk adress
2013-08-12 13:23 448developer.android.com/sdk/index ... -
android 结束进程
2013-07-29 22:01 702Android获取apk的版本及包名等信息 http://bl ... -
adnroid 4.0.3去掉虚拟导航栏
2013-07-27 20:54 1010http://blog.csdn.net/wfh1988/ar ... -
andorid全屏
2013-07-27 10:15 766super.onCreate(savedIns ... -
Foursquare
2012-10-12 17:22 0Foursquare -
sqllite brower
2012-09-11 23:05 641http://www.oschina.net/p/sqlite ... -
notice
2012-09-03 21:13 668http://tibaloga.iteye.com/blog/ ... -
音乐播放
2012-09-03 20:48 841package com.android.andrew; im ...
相关推荐
学习android的小小总结,其中有红色字体标记重点,非常有用的查询和学习文档。
android颜色背景颜色,字体颜色的总结。
1.1 设置Android Studio 自带的主题及包名字体大小 1.2 导入第三方主题: 下载了第三方的主题,然后执行: File——>Import Settings——>下载jar包所在位置 即可 二、Android Studio 字体的设置 2.1 编辑界面字体...
关于android添加第三方字体的方法 android-apt-compiler: [t1] res\layout\LinearLayout.xml: Invalid file name: must contain only [a-z0-9_.] Buttons in button bars should be borderless android 支持的距离...
android_设置字体样式.docx Android_用纯代码实现复杂界面.doc android+struts2.docx android—EditText.docx android—listview.docx android-Paint类介绍.docx android---tabhost.docx android——WebView...
总结一下以前自定义字体的方法 1 .通过findViewById找到view,然后一个个的去设置字体 Typeface customFont = Typeface.createFromAsset(this.getAssets(), "fonts/customFont.ttf"); TextView view = (TextView) ...
这段时间在做一个短信项目,需要实现短信中插入表情的功能,本一位非常困难,经过一段时间的研究,发现还是比较簡単的,现在总结如下。 以短信输入框为例,短信的输入框是一个EditText,它的append方法不仅可以...
目录 第1章 绪论 1 1.1课题背景 1 1.2国内外研究现状 2 1.3发展趋势 3 1.4课题研究意义 4 1.5论文结构安排 5 1.6本章小结 5 ...第6章 总结与展望 37 6.1结论 37 6.2进一步工作方向 37 致谢 38 参考文献 39
主要介绍了Android TextView字体颜色设置方法,结合实例形式总结分析了Android开发中TextView设置字体颜色的常用技巧,需要的朋友可以参考下
主要介绍了Android编程实现TextView字体颜色设置的方法,结合实例形式总结分析了Android针对TextView字体颜色设置的相关步骤与注意事项,具有一定参考借鉴价值,需要的朋友可以参考下
第6章 总结与展望…………………………………………………………………….…..………..…37 6.1 结论…………………………………………………………………………...…..……..….…37 6.2 进一步工作方向…………...
【项目资源】: 包含前端、后端、移动开发、操作系统、人工智能、物联网、信息化管理、数据库、硬件开发、大数据、课程资源、音视频、网站开发等各种技术项目的... 部分字体以及插图等来自网络,若是侵权请联系删除。
本文总结分析了Android EditText常用属性。分享给大家供大家参考,具体如下: android:hint=”请输入数字!”//设置显示在空间上的提示信息 android:numeric=”integer”//设置只能输入整数,如果是小数则是:...
自己总结的几点。。,关于在TextView中进行图文展现,,这个方法同样适用在Button,EditText中使用..
在android开发过程中,有的颜色记不清楚,所以总结了一下颜色;在开发过程中设置字体,背景或者其它的部分可以直接调用android:textColor="加入颜色的代码"。
看了一篇《关于使用Delphi XE10 进行android开发的一些总结》有些想说的。 以下内容有复制原文,正常字体显示的是原文,黑体是我想说的。 我并不想讨论什么样的开发语言更优秀,只希望能以我自己的体会、总结的使用...
主要介绍了Android编程常用技巧实例总结,包括Android对话框、分辨率、资源、字体等操作技巧,具有一定参考借鉴价值,需要的朋友可以参考下
Android 一种基于Linux的自由及开放源代码的操作系统,主要使用于移动设备,如智能手机和平板电脑,由Google公司和开放手机联盟领导开发 IOS 由苹果公司开发的移动操作系统 Webkit 一个开源的浏览器引擎,在手机上的...
这份文档是利用java语言...其中实现了记事本的文件保存、另存为、字体、自动换行等等的功能。除此之外,这份文档中的代码语言较为简洁明了,对于初学者阅读相对来说较为容易,希望这份文档可以帮助到更多热爱学习的人。
【项目资源】: 包含前端、后端、移动开发、操作系统、人工智能、物联网、信息化管理、数据库、硬件开发、大数据、课程资源、音视频、网站开发等各种技术项目的... 部分字体以及插图等来自网络,若是侵权请联系删除。