首页在AndroidManifest.xml中 application中设置一个主题
<application android:name="com.qiyuan.congmingtou.app.CMTApplication" android:allowBackup="true" android:icon="@drawable/ic_launcher" android:persistent="true" android:label="@string/app_name" android:theme="@style/AppTheme">
在style.xml中
<style name="AppTheme" parent="AppBaseTheme"> <item name="android:windowNoTitle">true</item> <item name="android:typeface">serif</item> </style>
Android中默认的字体样式有3中,
serif,
monospace,
sans,
*** 如果是 全局加载 第三方 字体 ,需重写 控件 (比如TextView)
先将 下载的 TTF 字体文件 放入 assets/fonts/f3.ttf
然后 重写TextView 如 TextViewMy.java
package com.mft.test; import android.content.Context; import android.graphics.Typeface; import android.util.AttributeSet; import android.util.Log; import android.widget.TextView; /** * Created by tk on 2017/5/5 0005. */ public class TextViewMy extends TextView { public TextViewMy(Context context) { super(context); setTypeface() ; } public TextViewMy(Context context, AttributeSet attrs) { super(context, attrs); setTypeface() ; } public TextViewMy(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setTypeface() ; } private void setTypeface(){ // 如果自定义typeface初始化失败,就用原生的typeface try{ setTypeface(Typeface.createFromAsset(getContext().getAssets(),"fonts/f3.ttf")); }catch(Exception e){ Log.i("MyApp", "加载第三方字体失败。") ; } } }
'然后在 布局文件中 就可以这样使用 了
<com.mft.test.TextViewMy android:text="A" android:id="@+id/key_a" android:tag="a" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/btn_zh_abc_key" android:layout_weight="1" android:textColor="@color/keyb_zh_abc_color" android:textSize="@dimen/zh_keyb_abc_font_size" android:gravity="center" />
相关推荐
android设置全局字体样式.rar,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。
设置 android全局各种字体样式 方便、简洁
Android 使用Font和style定义App全局字体样式,非常快速,之前有一份同样的代码,但是忘记删除一些东西了,导致文件特别大,重新上传了一份
全局字体设置,单独字体设置,附带阿里-惠普体字体包,
使用Font xml配合style统一更换App的所有字体样式,快速高效
涉及:语言设置、主题颜色、字体大小、字体样式、长短震动、铃声设置、Mp3播放服务、本地数据储存读写等,App必备实用功能集合 代码简明易懂,注释详细,适合初学者 使用开发工具 :Android Studio 3.2 开发环境:...
|--android 对话框样式 |--android 开机启动 |--android 挪动dialog的位置 |--android 控制对话框位置 |--android 根据uri获取路径 |--android 模拟器错误 |--android 横竖屏切换 |--android 获取mac地址 |--android...
Android 一种基于Linux的自由及开放源代码的操作系统,主要使用于移动设备,如智能手机和平板电脑,由Google公司和开放手机联盟领导开发 IOS 由苹果公司开发的移动操作系统 Webkit 一个开源的浏览器引擎,在手机上的...
:wine_glass: 滴水 一个用于Expo / React Native Web的简陋,响应Swift的设计系统。...自定义字体,全局编辑 响应式 通用(Android,iOS,Web等) 与世博会合作 与Vanilla React Native一起使用 与Next
样式化的组件 笑话/快照(可以使用更多) 通过ESLint / Prettier整理 导航就是React导航 项目结构: 屏幕:应用程序的所有屏幕 utils:全球助手 组件:全局组件 资产:图像,字体,乐透动画等 流程:流程定义 flow...
A 新增 选取 android 设备上的 profile 文件进行分析 详情 A 新增 WXML 面板支持自定义组件数据查看与实时修改 A 新增 WXML 面板支持使用键盘 (上下左右) navigate the DOM tree A 新增 WXML 面板支持右键操作 ...