android TextView字体切换
2015-07-06 19:44
621 查看
布局文件activity_main.xml 内容:
MaintActivity
资源文件放置位置
运行,测试搞定.
源代码:http://download.csdn.net/detail/ooppcool/8874189
<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" > <TextView android:id="@+id/mHelloWordTv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" /> </RelativeLayout>
MaintActivity
public class MainActivity extends Activity { /** 资源文件路径 */ public static final String FONTS_PATH = "fonts/GBK.TTF"; /**要改变字体的TextView*/ private TextView mHelloWordTv; /**字体*/ private Typeface mTf; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initViews(); } private void initViews() { mHelloWordTv = (TextView)findViewById(R.id.mHelloWordTv); mTf = Typeface.createFromAsset(getAssets(),FONTS_PATH); mHelloWordTv.setTypeface(mTf); } }
资源文件放置位置
运行,测试搞定.
源代码:http://download.csdn.net/detail/ooppcool/8874189
相关文章推荐
- Android 反编译 -smali语法
- Android Intents和Intent过滤器(二)
- Android Intents和Intent过滤器(一)
- Android Telephony纲要
- 国内Android SDK镜像
- MonkeyRunner源代码分析Android通信设备
- 初学_Android4高级编程-4 简单的Adapter
- 初学_Android4高级编程-3 自定义View
- 初学_Android4高级编程-2 Fragment
- 【分享】androidpn 作为Android推送方案存在的问题
- picasso-强大的Android图片下载缓存库
- android 文件保存到SD卡
- android 常用属性方法
- Android Studio 生成.so文件及 Android.mk文件解析
- android屏幕适配drawable,layout
- Android Studio使用笔记(随时添加)
- 使用Fragment完成Tab选项卡-Android Fragment应用实战
- Android(Lollipop/5.0) Material Design(四) 创建列表和卡片
- android 屏幕方向
- 利用Android反射与泛型机制写一个通用的Adapter类