android studio改字体,在Android Studio中更改字体样式的不同方法有哪些
在Android Studio中右键单击app&创建文件夹资产。
右键单击资产并创建文件夹字体。
下载.ttf文件,即fontName.ttf并粘贴到fonts文件夹中。
现在你必须做主要的事情。在你的包中创建一个类。
此类适用于TextView
public class Railway_Regular extends TextView {
public Railway_Regular(Context context, AttributeSet attrs) {
super(context, attrs);
this.setTypeface(Typeface.createFromAsset(context.getAssets(),"fonts/Raleway-Regular.ttf"));
}}这个类适用于Button
public class Railway_Regular_Btn extends Button {
public Railway_Regular_Btn(Context context, AttributeSet attrs) {
super(context, attrs);
this.setTypeface(Typeface.createFromAsset(context.getAssets(),"fonts/Raleway-Regular.ttf"));
}}此类适用于EditText
public class Railway_Regular_EdTx extends EditText {
public Railway_Regular_EdTx(Context context, AttributeSet attrs) {
super(context, attrs);
this.setTypeface(Typeface.createFromAsset(context.getAssets(),"fonts/Raleway-Regular.ttf"));
}}像这些你可以为你所有的小部件创建类。将fontname.ttf引用到您的类中。
现在,对于set textview,你的字体就是这样做的。
对于TextView
android:padding="5sp"
android:id="@+id/test_nameDR"
android:layout_marginTop="4dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Details Text"
android:textColor="@color/black"
android:textSize="14sp"/>对于Button
android:id="@+id/revSubmit"
android:background="@color/greenDeep"
android:layout_marginTop="-54dp"
android:layout_width="match_parent"
android:layout_height="54dp"
android:textColor="@color/white"
android:textSize="16dp"
android:text="SUBMIT REVIEW"
/>对于EditText
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="15dp"
android:textColorHint="@color/lightgray"
android:textSize="14dp"
android:background="@drawable/edit_text"
android:id="@+id/email_id"
android:hint="Email Id"
android:inputType="textEmailAddress" />第二种更改字体的方法:
Typeface typeface,typeface2;
typeface = Typeface.createFromAsset(this.getAssets(),"fonts/Raleway-Regular.ttf");
typeface2 = Typeface.createFromAsset(this.getAssets(),"fonts/Raleway-SemiBold.ttf");
button1.setTypeface(typeface);
edit_text1.setTypeface(typeface2);
android studio改字体,在Android Studio中更改字体样式的不同方法有哪些相关推荐
- html语言更改字体大小,在HTML中更改字体大小
我有一个包含的CSS .warning{ margin-top: 1em; padding: 10px 5px 15px 45px; border-color: #680000; border-wid ...
- android 更改字体_如何在Android中更改字体
android 更改字体 Ben Stockton 本·斯托克顿 Android offers plenty of options to customize the appearance of you ...
- android设置应用字体大小,在Android应用程序改变的TextView的字体大小从原始设置更改字体大小(Font size...
我想在我的应用程序指定我自己的文字大小,但我有这样一个问题. 当我在设备设置中更改字体大小,我的应用程序的字体大小TextView也会改变. Answer 1: 其实,设置字体大小只影响大小sp . ...
- python怎么改字体大小_如何使用python在excel中更改字体大小
我必须创建字体为Times New Roman.字体大小为16的内容.如何使用python脚本创建? 我的示例脚本import xlwt workbook = xlwt.Workbook(encodi ...
- win10修改系统字体(替换OneNote中Calibri字体)
微软的OneNote还是很好用的,但是字体问题一直是一个吐槽点. 我自己就去微软官网吐槽了好几次,然而并没有什么用.我说设置默认字体为consolas完全无法生效,再次输入笔记时,中文自动改为微软雅黑 ...
- unity 发光字体_Unity3D 设置OnGUI中的字体样式、字体颜色、字体大小等
1:字体样式 从系统盘,如C:\Windows\Fonts找一个.ttf格式的字体库,放到Assets目录下. 此时选中该字体库,在Inspector面板可以修改字体的大小,试了一下修改字体的颜色(F ...
- html页面icon字体无法显示,bootstrap中icon字体图标怎么不显示?
bootstrap中icon字体图标怎么不显示?下面本篇文章给大家介绍一下Bootstrap字体图标不显示问题.有一定的参考价值,有需要的朋友可以参考一下,希望对大家有所帮助. 问题: bootstr ...
- 微信小程序可以加服务器上的字体,微信小程序中自定义字体
微信小程序支持自定义字体开放出来也有段时间,这边整理下使用自定义字体中,容易忽略的一些问题,和简便的全局自定义方式.如果是同时加载两种字体包,先下载下来的会被后下载下来的字体包给覆盖. 官网接口文档 ...
- css 字体图标更改颜色_在CSS中更改字体
css 字体图标更改颜色 CSS字体属性 (CSS font properties ) Font properties in CSS is used to define the font family ...
最新文章
- plsql连接oracle报错12514,plsql 登录 oracle11 12514 错误的处理方法
- 在centos下报错:-bash: apt-get: 未找到命令
- php读取usb设备信息,急,请问如何获取USB设备的路径,非HID类型
- 【深度学习】——物体检测的难点
- 蓝桥杯2015初赛-加法变乘法-枚举
- C#复习笔记(3)--C#2:解决C#1的问题(可空值类型)
- pyqt5生成py的文件为什么是c 语言,如何使用PyQt5在python中创建文件对话框
- 2013q3 android ios 用户接入网络方式pv占比分布,2012年移动互联网发展分析.pdf
- 322. 零钱兑换(JavaScript)
- libgc 加 .mak 在 vc6 vs2008 中的编译方法
- 服务器主板型号详解,支持Intel Xeon的主板
- COMSOL电磁仿真案例——感应线圈
- greensock下载_GreenSock动画平台初学者指南
- windows批处理脚本bat命令解析【10】如何运行cmd命令3bat批处理文件中的注释
- Fiddler自动回复器伪造回复
- 跨域 SameSite secure
- ASP.NET MVC入门视频教程
- 推荐几个常用的Python扩展工具包
- android x86 5.1 微信,微信5.1终于来了!微信5.1安卓版正式发布
- 28 关于 Finalizer