Lập trình Android tiếng Việt - Chapter 9: Android Fonts

Developers may add any font to their application by following the next steps:

 

Create the /fonts folder in the /assets directory.

 

Copy any fonts you plan to use into the new folder.

 

Use Java code to bind the font with the UI widget wanting to display the custom typeface (see example).

 

pptx12 trang | Chuyên mục: Android | Chia sẻ: dkS00TYs | Lượt xem: 2227 | Lượt tải: 5download
Tóm tắt nội dung Lập trình Android tiếng Việt - Chapter 9: Android Fonts, để xem tài liệu hoàn chỉnh bạn click vào nút "TẢI VỀ" ở trên
Click to edit Master title style Click to edit Master text styles Second level Third level Fourth level Fifth level 4/18/2011 ‹#› Android Fonts Notes are based on: The Busy Coder's Guide to Android Development by Mark L. Murphy Copyright © 2008-2009 CommonsWare, LLC. ISBN: 978-0-9816780-0-9 & Android Developers  9 2 9. Android – UI – Fonts Fonts 2 Android naturally provides three fonts: sans: 	An m is wider than i, mmm iiii serif:	 	An m is wider than i, mmm iiii monospaced:	An mmm is not wider than iii 3 9. Android – UI – Fonts Fonts 3 Also know as: Roman Type Grotesque or Gothic Source:  4 9. Android – UI – Fonts Fonts 4 Developers may add any font to their application by following the next steps: Create the /fonts folder in the /assets directory. Copy any fonts you plan to use into the new folder. Use Java code to bind the font with the UI widget wanting to display the custom typeface (see example). 5 9. Android – UI – Fonts Fonts 5 Example: Getting ready to use the Jokerman.TTF font. Original font taken from c:\Windows\Fonts 6 9. Android – UI – Fonts Fonts 6 Example: Display the Hello World ! message using different fonts. Using the font: Jokerman.TTF Note: If you are using Windows XP look into the folder: c:\Windows\Fonts for fonts installed in your machine. Consult the page:  for additional information in manipulating fonts. 7 9. Android – UI – Fonts Fonts 7 Example Application: Showing different FONT types. 8 9. Android – UI – Fonts Fonts 8 9 9. Android – UI – Fonts Fonts 9 10 9. Android – UI – Fonts Fonts 10 11 9. Android – UI – Fonts Fonts 11 To be displayed using a custom font 12 9. Android – UI – Fonts Fonts 12 package cis493.androfontsdemo; import android.app.Activity; import android.graphics.Typeface; import android.os.Bundle; import android.widget.TextView; public class AndroFontDemo extends Activity { @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); // bind the "custom" textview with chosen font TextView tvCustom=(TextView)findViewById(R.id.custom); Typeface myNewFace=Typeface.createFromAsset( 	getAssets(), "fonts/Jokerman.TTF“ ); tvCustom.setTypeface(myNewFace); } } 13 13 	09 - Android – UI – Fonts Fonts 13 Questions ? 

File đính kèm:

  • pptxLập trình Android tiếng Việt - Chapter 9 Android Fonts.pptx
Tài liệu liên quan