2015-02-23 23 views
1

我在做這一塊聊天應用我使用圖標字體參考font awesome,我已經通過設置字體使用我正在訪問的圖標後保存的ttf文件到我的項目資產的文件夾,問題是,我想改變大小,圖標的顏色font.Please幫我如何更改字體圖標顏色的Android

<TextView 
     android:id="@+id/landing_drawer_image" 
     android:layout_width="@dimen/width_40" 
     android:layout_height="@dimen/height_40" 
     android:layout_marginLeft="@dimen/margin_15" 
     android:textColor="@color/grey_black_1000" 
     android:gravity="center_vertical" 
     android:text="Drawable" 
     /> 

viewHolder.drawerItemImage.setText("A"); 
+0

安置自己的XML請 – 2015-02-23 10:51:12

+0

當你這樣做會發生什麼:圖標。 setTextColor(Color RED); – 2015-02-23 10:51:37

+0

嘗試呈現html數據並將本地css應用於它 – KOTIOS 2015-02-23 10:56:16

回答

2

你可以試試這個:

設置在colors.xml顏色:

<color name="test">#0f0f0f</color> 

在你的XML做到這一點:

<TextView 
     android:id="@+id/landing_drawer_image" 
     android:layout_width="@dimen/width_40" 
     android:layout_height="@dimen/height_40" 
     android:layout_marginLeft="@dimen/margin_15" 
     android:textColor="@color/test" 
     android:gravity="center_vertical" 
     android:text="Drawable" 
     /> 

要設置TypeFace您可以通過兩種方式

1.-

Typeface font = Typeface.createFromAsset(
getContext().getAssets(), 
"fonts/YourTypeFace.ttf"); 
YourTextView.setTypeface(font); 

2:android:typeface="YOURTTF"

要設置做你TextSize你必須在你的xml文件中添加

android:textSize="@dimen/font_size"/> 

試試這個,如果你有任何問題,讓我知道,希望我的回答或多或少幫助你:)

3

試試這個

Typeface font = Typeface.createFromAsset(getAssets(), 
      "fontawesome-webfont.ttf"); 

    gmail_icon.setTypeface(font); 

    gmail_icon.setTextColor(getResources().getColor(R.color.white));