Ranjit
Ranjit

Reputation: 5150

Is it possible to use fonts for Images/icons in Android

I Just know that we can use fonts for text only by using the TypeFace class. But can anyone please confirm me about images.

I have added all my custom fonts(.ttf) inside asset/fonts folder. Placed some ImageViews in their appropriate place in my app. And trying to use fonts to set images on them.

I have googled for a long time, but unfortunately unable to find any satisfied hint or help.

Can any one please help me to go forward from the current step.

Upvotes: 2

Views: 4468

Answers (2)

user3796978
user3796978

Reputation: 91

You can use font awesome. Import the android-iconify/1.0.6 jar library from http://repo1.maven.org/maven2/com/joanzapata/android/android-iconify/1.0.6/
and you can use IconTextView

  <IconTextView
            android:id="@+id/image"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:padding="10dp"
            android:text="{fa-mobile}"
            android:textColor="#9fd46c"
            android:textSize="30dp"
            />

Upvotes: 2

CommonsWare
CommonsWare

Reputation: 1007359

Placed some ImageViews in their appropriate place in my app. And trying to use fonts to set images on them.

ImageView accepts images. Whatever set of pixels or vectors are in a font, they are not images from the standpoint of ImageView. The simplest way to display material from a custom font is through TextView, though you are welcome to implement your own Drawable and attempt to use that with an ImageView, or draw straight to the Canvas (e.g., in a custom widget).

Upvotes: 2

Related Questions