简单几步就能够完成android
简单的效果图:web
在Android Studio 上的建立步骤为:app
在 src/main
上右键 --> New
--> Folder
--> Assets Folder
.字体
将FontAwesome 字体文件copy到assets指定的路径,这里我放在assets/font/fontawesome-webfont.ttf
.ui
<string name="fa_car"></string> <string name="fa_apple"></string> <string name="fa_android"></string>
//...
<TextView
android:id="@+id/tv_1" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/fa_car" android:textSize="20sp" android:textColor="@color/cardview_shadow_start_color" /> <TextView android:id="@+id/tv_2" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/fa_apple" android:textSize="24sp" android:textColor="@color/colorPrimaryDark" /> <TextView android:id="@+id/tv_3" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/fa_android" android:textSize="48sp" android:textColor="@color/colorAccent" /> //...
TextView tv_1 = (TextView)findViewById(R.id.tv_1);
TextView tv_2 = (TextView)findViewById(R.id.tv_2);
TextView tv_3 = (TextView)findViewById(R.id.tv_3);
//获取assets文件夹里的字体文件 Typeface font = Typeface.createFromAsset(getAssets(), "font/fontawesome-webfont.ttf"); //给指定的TextView加载字体 tv_1.setTypeface(font); tv_2.setTypeface(font); tv_3.setTypeface(font);