1

I am making one chat application in this i am using icon fonts with reference font awesome,I have saved ttf file into my project assets folder after that i am accessing icons using by setting typeface,problem is i want to change size,color of icon font.Please help me

 <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");
skyshine
  • 2,767
  • 7
  • 44
  • 84

2 Answers2

3

try this

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

    gmail_icon.setTypeface(font);

    gmail_icon.setTextColor(getResources().getColor(R.color.white));
Seema Nagar
  • 91
  • 1
  • 6
2

You could try this :

Set a color in your colors.xml :

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

In your XML do this :

<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"
        />

To set the TypeFace you can do it by two ways

1.-

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

2.- android:typeface="YOURTTF"

To set your TextSize you have to add in your xml file

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

Try this and if you have any problem let me know, hope my answered helped you somehow :)

Skizo-ozᴉʞS ツ
  • 19,464
  • 18
  • 81
  • 148