android chapter 09 fonts

Upload: x-man

Post on 06-Apr-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/3/2019 Android Chapter 09 Fonts

    1/7

    10/19/2009

    1

    9

    n ro

    YVictorMatos

    ClevelandStateUniversity

    Notesarebasedon:'TheBusy oder'sGuidetoAndroidDevelopment

    byMarkL.Murphy

    Copyright20082009CommonsWare,LLC.

    ISBN:9780981678009

    &AndroidDevelopers

    http://developer.android.com/index.html

    9.Android UI Fonts

    Fonts

    Androidnaturallyprovidesthreefonts:

    sans: n m s w er an , mmm

    serif: An m is wider than i, mmm iiii

    monospaced: An mmm is not wider than iii

    22

  • 8/3/2019 Android Chapter 09 Fonts

    2/7

    10/19/2009

    2

    9.Android UI Fonts

    Fonts

    Alsoknowas:

    Grotesqueor

    Gothic

    33

    RomanType

    Source:http://en.wikipedia.org/wiki/Serif

    9.Android UI Fonts

    Fonts

    Developersmayaddanyfonttotheirapplicationby

    followingthenextsteps:

    1. Createthe /fonts folderinthe/assetsdirectory.2. Copyanyfonts youplantouseintothenewfolder.3. UseJavacodetobindthefontwiththeUIwidgetwantingto

    44

    .

  • 8/3/2019 Android Chapter 09 Fonts

    3/7

    10/19/2009

    3

    9.Android UI Fonts

    Fonts

    Example:GettingreadytousetheJokerman.TTF font.

    Originalfonttakenfrom c:\Windows\Fonts

    55

    9.Android UI Fonts

    Fonts

    Example:

    DisplaytheHelloWorld!messageusingdifferentfonts.

    Usingthefont:

    Jokerman.TTF

    66

    Note:

    IfyouareusingWindowsXPlookintothefolder:c:\Windows\Fontsforfonts

    installedinyourmachine.

    Consultthepage:http://www.ascendercorp.com/support/windows/ for

    additionalinformationinmanipulatingfonts.

  • 8/3/2019 Android Chapter 09 Fonts

    4/7

    10/19/2009

    4

    9.Android UI Fonts

    Fonts

    ExampleApplication:ShowingdifferentFONTtypes.

    77

    9.Android UI Fonts

    Fonts

  • 8/3/2019 Android Chapter 09 Fonts

    5/7

    10/19/2009

    5

    9.Android UI Fonts

    Fonts

  • 8/3/2019 Android Chapter 09 Fonts

    6/7

    10/19/2009

    6

    9.Android UI Fonts

    Fonts

    < extV ew

    android:id="@+id/labelCustom"

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"

    android:layout_marginRight="24px"

    android:text="custom:"

    android:textSize="20sp"

    android:background="#ff006666"

    >

    9.Android UI Fonts

    Fonts

    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);

    " "

    1212

    TextView tvCustom=(TextView)findViewById(R.id.custom);

    Typeface myNewFace=Typeface.createFromAsset(

    getAssets(), "fonts/Jokerman.TTF );

    tvCustom.setTypeface(myNewFace);

    }

    }

  • 8/3/2019 Android Chapter 09 Fonts

    7/7

    10/19/2009

    7

    09 Android UI Fonts

    Fonts

    dx| Rx| R

    131313