安卓开发入门之自定义字体(翻译)
来源:互联网 发布:android vr java 编辑:程序博客网 时间:2024/05/16 07:25
原文链接
https://www.tutorialspoint.com/android/android_custom_fonts.htm
1.MainActivity.java文件
public class MainActivity extends ActionBarActivity { TextView tv1,tv2; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); tv1=(TextView)findViewById(R.id.textView3); tv2=(TextView)findViewById(R.id.textView4); Typeface face= Typeface.createFromAsset(getAssets(), "font/font.ttf"); tv1.setTypeface(face); Typeface face1= Typeface.createFromAsset(getAssets(), "font/font1.ttf"); tv2.setTypeface(face1); }}
2.activity_main.xml文件
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Typeface" android:id="@+id/textView" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:textSize="30dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Tutorials Point" android:id="@+id/textView2" android:layout_below="@+id/textView" android:layout_centerHorizontal="true" android:textSize="35dp" android:textColor="#ff16ff01" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Tutorials Point" android:id="@+id/textView3" android:layout_centerVertical="true" android:textSize="45dp" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Tutorials Point" android:id="@+id/textView4" android:layout_below="@+id/textView3" android:layout_alignLeft="@+id/textView3" android:layout_alignStart="@+id/textView3" android:layout_marginTop="73dp" android:textSize="45dp" /> </RelativeLayout>
3.AndroidManifest.xml文件
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.sairamkrishna.myapplication" > <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application></manifest>
源码下载
http://download.csdn.net/detail/zhangxiangliang2/9874915
阅读全文
1 0
- 安卓开发入门之自定义字体(翻译)
- 安卓开发入门之自定义View(翻译)
- 安卓开发入门之自定义柱状图
- 安卓开发入门之底部导航BottomNavigationView(翻译)
- 安卓开发入门之图片缩放(翻译)
- 安卓开发入门之自动补全文本(翻译)
- 安卓开发入门之小部件Widgets(翻译)附源码
- 安卓开发入门之主题与样式必看知识点(翻译)
- 安卓开发入门之系统下载管理工具DownloadManager-第一部分(翻译)
- 安卓开发入门之系统下载管理工具DownloadManager-第二部分(翻译)
- 安卓开发入门之系统下载管理工具DownloadManager-第三部分(翻译)
- 安卓 使用字体包 自定义字体
- 安卓textview自定义字体
- 浅谈安卓自定义字体
- 安卓开发之自定义Dialog
- 安卓开发之发送自定义广播
- 安卓开发之自定义对话框
- Android开发之自定义字体
- Java线程:线程状态的转换
- 底下菜单栏的实现
- python中字符串的翻转(方法总结)
- Proteus 新手使用教程
- 170619 利用python实现matlab中的agwn(signal,SNR)函数
- 安卓开发入门之自定义字体(翻译)
- Android面试题
- c++ 基础知识入门
- SpringMVC4.0使用properties file
- mentohust联网报错“系统提示:用户使用了不允许的接入方式!(有线网络请选择“有线1x上网”服务)”
- javascript--面向对象(五)动态原型模式
- oracle_函数
- Java线程:线程的同步与锁
- Unity集成测试的一些思路