Android設置字體

android:textAppearance
設置文字外觀。如「?android:attr/textAppearanceLargeInverse
」這裏引用的是系統自帶的一個外觀,?表示系統是否有這種外觀,不然使用默認的外觀。可設置的值以下:textAppearanceButton/textAppearanceInverse/textAppearanceLarge/textAppearanceLargeInverse/textAppearanceMedium/textAppearanceMediumInverse/textAppearanceSmall/textAppearanceSmallInverse

textView.getPaint().setFlags(Paint. UNDERLINE_TEXT_FLAG ); //下劃線

textView.getPaint().setAntiAlias(true);//抗鋸齒

textview.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG); //中劃線

setFlags(Paint. STRIKE_THRU_TEXT_FLAG|Paint.ANTI_ALIAS_FLAG);  // 設置中劃線並加清晰 

textView.getPaint().setFlags(0);  // 取消設置的的劃線

自定義建立字型java

      //自定義字體字型android

       custom=newTextView(this);字體

       //字體MgOpenCosmeticaBold.ttf放置於assets/font/路徑下this

       typeface=Typeface.createFromAsset(getAssets(),"font/MgOpenCosmeticaBold.ttf");spa

       custom.setTypeface(typeface);code

       custom.setText("Custom Font FYI");get

       custom.setTextSize(20.0f);  
class

       //設置字體顏色引用

       custom.setTextColor(Color.CYAN);di

        linearLayout.addView(custom,newLinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));

相關文章
相關標籤/搜索