Android 自定义字体,设置字体

效果图

 

 

 

实现代码:

1、先下载字体文件.ttf

下载链接:http://font.chinaz.com/maobiziti.html

2、main文件夹下创建fonts文件夹,.ttf文件复制到fonts文件夹下

3、读取ttf文件

 

List<Typeface> mTypefaceList = new ArrayList();
private void getFontFromAssets() {mTypefaceList.add(Typeface.DEFAULT);String[] fontNameList = null;AssetManager assetManager = getAssets();try {fontNameList = assetManager.list("fonts");} catch (IOException e) {e.printStackTrace();}for (int i = 0; i < fontNameList.length; i++) {String fontPath = "fonts" + "/" + fontNameList[i];Typeface typeface = Typeface.createFromAsset(assetManager, fontPath);//根据路径得到TypefacemTypefaceList.add(typeface);}}

4、设置文本字体:

textView.setTypeface(mTypefaceList.get(1));
textView2.setTypeface(mTypefaceList.get(2));
textView3.setTypeface(mTypefaceList.get(3));
textView4.setTypeface(mTypefaceList.get(4));

 

  1. noraml (普通字体,系统默认使用的字体)
  2. sans(非衬线字体)
  3. serif (衬线字体)
  4. monospace(等宽字体)

 

android:typeface="serif"

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/415121.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

docker 安装 centos

1、设置docker 镜像加速 三个源 名称路径网易https://hub-mirror.c.163.com/阿里云https://<你的ID>.mirror.aliyuncs.com七牛云加速器https://reg-mirror.qiniu.com "registry-mirrors":["https://hub-mirror.c.163.com/","https://reg-mirr…

工作177:时间戳转换

main.js // 将时间戳转日期格式的过滤器 Vue.filter(dateFormat, (dataStr) > {var time new Date(dataStr);function timeAdd0(str) {if (str < 10) {str 0 str;}return str}var y time.getFullYear();var m time.getMonth() 1;var d time.getDate();var h time…

二.java下使用RabbitMQ实现hello world

上一篇文章介绍了windows环境下的安装和配置rabbitMQ&#xff0c;具体戳这边&#xff0c;一.windows环境下rabbit的的安装和配置。 现在我们可以着手编写hello world程序了&#xff0c;一窥RabbitMQ的效用&#xff0c;从rabbitmq的官网的get start进入rabbitMQ文档学习区&#…

工作180:前端是业务需求理解

1做一个系统之前 要明确数据的一个处理流程 才能避免做返工操作

docker centos ssh

1、创建一个容器 docker run -d -p 18022:22 -p 18000:8000 --privileged -v /Users/caowei/share:/share --name yf c17f22223248 /usr/sbin/init 2、进入容器 docker exec -it 39550a9d4610 /bin/bash 3、安装openssh和openssh-server yum install -y passwd openssh op…

Android自定义view详解,使用实例,自定义属性,贝塞尔曲线

//只会触发执行onDraw方法&#xff0c;只会改变绘制里面的内容,条目的绘制 invalidate(); //只会触发执行onDraw方法&#xff0c;但是可以在子线程中刷新 postInvalidate(); //view的布局参数改变之后刷新&#xff0c;比如view的宽度和高度都修改了&#xff0c;只能通过reques…

前端学习(2679):安装mysql_front

mysql front安装与使用教程 2020-04-10 11:32 更新mysql front一种小巧的管理Mysql的应用工具&#xff0c;那么这个工具该如何安装和使用呢&#xff1f;一起来看看吧。 一&#xff0c;mysql前端下载&#xff1a; mysql front下载地址&#xff1a;点击下载 二&#xff0c;mysql前…

Android RecyclerView 向上偏移解决、添加自定义分割线,瀑布流,ScrollView嵌套RecyclerView滑动卡顿

向上偏移解决 android:focusableInTouchMode"true" android:focusable"true" android:fillViewport"true" 卡顿解决方法 recyclerViewwg.setHasFixedSize(true); recyclerViewwg.setNestedScrollingEnabled(false); 删除条目&#xff1a; l…

前端学习(2678):懂代码之表格BaseTable编辑操作

第一步:编辑操作 <template slot-scope"scope"><el-buttontype"text"icon"el-icon-edit"click"handleEdit(scope.$index, scope.row)">编辑</el-button></template> 第二步 进行编辑处理 // 编辑操作handle…

工作182:表格渲染

<el-table :data"tableData" style"width: 100%" border> <!-- <el-table-column label"id" prop"1" align"center"></el-table-column>--><!--渲染账号名称--><el-table-column l…

Android 集成支付宝支付,支付宝支付2.0

成功起调支付宝支付 下载支付sdk复制到libs文件夹下并add as library&#xff1a;https://docs.open.alipay.com/54/104509 1、首先申请支付宝 企业账户 链接&#xff1a;https://memberprod.alipay.com/account/reg/enterpriseIndex.htm 备注&#xff1a;企业账户是以邮箱申…

docker centos node nginx

1、docker pull centos:centos8 2、进入容器 docker run -it centos:centos8 /bin/bash 3、安装git yum install -y git 4、安装nvm git clone https://github.com/creationix/nvm.git source nvm/nvm.sh 5、修改环境变量 vi ~/.bash_profile 加入source nvm/nvm.sh 更新 sour…

Appium——api常用函数

appium常用函数介绍&#xff1a;获取页面信息&#xff1a;1、 def get_current_activity(cls, driver):获取当前页面的activity:param driver::return:return driver.current_activity2、 def get_current_pagesource(cls, driver):获取当前页面源码:param driver::return: 返回…

工作183:动态渲染数据 数据在数字字典里面

1接口调用 /*调用接口*/created() {/*动态渲染content_type接口*/getAction("/dict/list",{dict_code:"content_type"}).then(res>{this.content_typeres.data})/*动态渲染*/getAction("/dict/list",{dict_code:"resource_type"})…

Android 集成微信支付详解

打包后才能起调支付 微信支付成功起调 微信skd下载&#xff1a;https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter11_1 签名APK下载&#xff1a;https://open.weixin.qq.com/zh_CN/htmledition/res/dev/download/sdk/Gen_Signature_Android.apk 1、首先到微信.…

工作184:自定义事件

1子组件 mongo.vue <template><button click"eat">按钮</button> </template><script> export default {created() {this.$on("eat", function(fruit) {console.log("子组件接收自己发射的事件");});},methods:…

cesium label 显示隐藏到地底下

今天在写label的时候&#xff0c;发现高度为0时&#xff0c;label显示不全&#xff0c;影响用户体验&#xff0c;代码如下&#xff1a; window.labelEntity viewer.entities.add({label: {show: false,showBackground: true,font: "14px monospace",horizontalOrigi…

工作186:实际案例解决vue+el-element二级联动,选项选择后不显示的问题

1组件 <el-form-item label"所属部门" :label-width"formLabelWidth"><select-form change"DepartmentList" v-model"form.department_id" /></el-form-item><!-- <el-form-item prop"business_module&…