TAILIEUCHUNG - Bắt Đầu Với Android (P.4)

Tham khảo tài liệu 'bắt đầu với android ()', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Page 127 Friday April 10 2009 3 34 PM CHAPTER 12 FONTS 127 TextView android id @ id custom android text Hello world android textSize 20sp TableRow TableLayout This layout builds a table showing short samples of four fonts. Notice how the first three have the android typeface attribute whose value is one of the three built-in font faces . sans . The three built-in fonts are very nice. However it may be that a designer or a manager or a customer wants a different font than one of those three. Or perhaps you want to use a font for specialized purposes such as a dingbats font instead of a series of PNG graphics. The easiest way to accomplish this is to package the desired font s with your application. To do this simply create an assets folder in the project root and put your TrueType TTF fonts in the assets. You might for example create assets fonts and put your TTF files in there. Then you need to tell your widgets to use that font. Unfortunately you can no longer use layout XML for this since the XML does not know about any fonts you may have tucked away as an application asset. Instead you need to make the change in Java code public class FontSampler extends Activity Override public void onCreate Bundle icicle icicle setContentView TextView tv TextView findViewById Typeface face getAssets fonts face Here we grab the TextView for our custom sample then create a Typeface object via the static createFromAsset builder method. This takes the application s AssetManager from getAssets and a path within your assets directory to the font you want. Then it is just a matter of telling the TextView to setTypeface providing the Typeface you just created. In this case we are using the Handmade Typewriter2 font see Figure 12-1 . 2. http typoasis designers klein07 text01 Page 128 Friday April 10 2009 3 34 PM

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.