Is it possible to set an Icon in ActionBar "Text" using FontAwesome?
I have tried this way...
My menu item like that..
<item
android:id="@+id/action_chat"
android:orderInCategory="100"
android:title="@string/action_chat"
app:showAsAction="always"
android:actionLayout="@layout/chat_menu_icon"/>
My 'chat_menu_icon.xml'
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<com.bitmakers.techmonster.textview.FontAusomeTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoLink="web"
android:id="@+id/test"
android:gravity="center|bottom"
android:text="@string/action_chat"
android:textSize="24sp"
android:textStyle="bold" />
</LinearLayout>
My Custom Font Class
package com.bitmakers.techmonster.textview;
import android.content.Context;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.TextView;
public class FontAusomeTextView extends TextView {
public static Typeface m_typeFace = null;
public FontAusomeTextView(Context context) {
super(context);
// TODO Auto-generated constructor stub
if (isInEditMode()) {
return;
}
loadTypeFace(context);
}
public FontAusomeTextView(Context context, AttributeSet attrs) {
super(context, attrs);
if (isInEditMode()) {
return;
}
loadTypeFace(context);
}
public FontAusomeTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
if (isInEditMode()) {
return;
}
loadTypeFace(context);
}
private void loadTypeFace(Context context) {
if (m_typeFace == null)
m_typeFace = Typeface.createFromAsset(context.getAssets(),
"fonts/fontawesome-webfont.ttf");
this.setTypeface(m_typeFace);
}
}
It is working when i using it in normal textview