<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_height="wrap_content" android:typeface="monospace" android:id="@+id/monospaceTxt" android:layout_width="fill_parent" android:text="Monospace: The quick brown fox jumps over the lazy dog" android:background="#424242"> </TextView> <TextView android:layout_height="wrap_content" android:typeface="sans" android:id="@+id/sansTxt" android:layout_width="fill_parent" android:text="sans: The quick brown fox jumps over the lazy dog"> </TextView> <TextView android:layout_height="wrap_content" android:typeface="serif" android:layout_width="fill_parent" android:text="serif: The quick brown fox jumps over the lazy dog" android:id="@+id/serifTxt" android:background="#424242"> </TextView> </LinearLayout>
Quick Explanation
Changing the font on xml is just one attribute and that is android:typeface. Any view/components that extends TextView would instantly have a typeface attribute.
Here is how you can set this as your layout in your java code
Update History
Jan 17, 2012 - Visual Update
No comments:
Post a Comment