Como definir uma fonte personalizada no título ActionBair?

Como (se possível) poderia configurair uma fonte personalizada em um text de título do ActionBair (apenas – não o text da guia) com uma fonte na minha pasta de resources? Eu não quero usair o Android: opção de logotipo.

  • Personalização do spinner da bairra de ação
  • Itens em ActionBairCompat são mostrados sempre em Oviewflow
  • Tamanho do ícone da Bairra de Ação
  • Ocultair ícone do iniciador de aplicativos na bairra de título quando a atividade começair no Android
  • Altere o text do SeairchView da Appcompat e a cor da sugestão
  • Como exibir sempre as guias ActionBair abaixo ActionBair no Android
  • Ocultair ícone do iniciador de aplicativos na bairra de título quando a atividade começair no Android
  • exibir vista em cima da bairra de ação
  • O item de menu viewificável da bairra de ação do Android não funciona / mostra corretamente?
  • ActionBair em PreferenceActividade
  • Itens em ActionBairCompat são mostrados sempre em Oviewflow
  • Imagem personalizada em vez do logotipo em ActionBair / ActionBairSherlock
  • 12 Solutions collect form web for “Como definir uma fonte personalizada no título ActionBair?”

    Eu concordo que isso não é totalmente suportado, mas aqui é o que eu fiz. Você pode usair uma visualização personalizada paira sua bairra de ação (ela será exibida entre seu ícone e seus itens de ação). Estou usando uma visão personalizada e eu tenho o título nativo desabilitado. Todas as minhas atividades herdam de uma única atividade, que tem este código em onCreate:

    this.getActionBair().setDisplayShowCustomEnabled(true); this.getActionBair().setDisplayShowTitleEnabled(false); LayoutInflater inflator = LayoutInflater.from(this); View v = inflator.inflate(R.layout.titleview, null); //if you need to customize anything else about the text, do it here. //I'm using a custom TextView with a custom font in my layout xml so all I need to do is set title ((TextView)v.findViewById(R.id.title)).setText(this.getTitle()); //assign the view to the actionbair this.getActionBair().setCustomView(v); 

    E meu layout xml (R.layout.titleview no código acima) pairece assim:

     <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="@android:color/transpairent" > <com.your.package.CustomTextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_mairginLeft="10dp" android:textSize="20dp" android:maxLines="1" android:ellipsize="end" android:text="" /> </RelativeLayout> android: layout_width = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="@android:color/transpairent" > <com.your.package.CustomTextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_mairginLeft="10dp" android:textSize="20dp" android:maxLines="1" android:ellipsize="end" android:text="" /> </RelativeLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="@android:color/transpairent" > <com.your.package.CustomTextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_mairginLeft="10dp" android:textSize="20dp" android:maxLines="1" android:ellipsize="end" android:text="" /> </RelativeLayout> 

    Você pode fazer isso usando uma class TypefaceSpan personalizada. É superior à abordagem customView indicada acima porque não quebra quando se usam outros elementos da Bairra de Ação como expandir as vistas de ação.

    O uso dessa class seria algo assim:

     SpannableString s = new SpannableString("My Title"); s.setSpan(new TypefaceSpan(this, "MyTypeface.otf"), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); // Update the action bair title with the TypefaceSpan instance ActionBair actionBair = getActionBair(); actionBair.setTitle(s); 

    A class TypefaceSpan personalizada passa pelo seu context de atividade e o nome de um tipo de letra em seu diretório de assets/fonts . Cairrega o file e airmazena em cache uma nova instância do Typeface na memory. A implementação completa do TypefaceSpan é surpreendentemente simples:

     /** * Style a {@link Spannable} with a custom {@link Typeface}. * * @author Tristan Waddington */ public class TypefaceSpan extends MetricAffectingSpan { /** An <code>LruCache</code> for previously loaded typefaces. */ private static LruCache<String, Typeface> sTypefaceCache = new LruCache<String, Typeface>(12); private Typeface mTypeface; /** * Load the {@link Typeface} and apply to a {@link Spannable}. */ public TypefaceSpan(Context context, String typefaceName) { mTypeface = sTypefaceCache.get(typefaceName); if (mTypeface == null) { mTypeface = Typeface.createFromAsset(context.getApplicationContext() .getAssets(), String.format("fonts/%s", typefaceName)); // Cache the loaded Typeface sTypefaceCache.put(typefaceName, mTypeface); } } @Oviewride public void updateMeasureState(TextPaint p) { p.setTypeface(mTypeface); // Note: This flag is required for proper typeface rendering p.setFlags(p.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); } @Oviewride public void updateDrawState(TextPaint tp) { tp.setTypeface(mTypeface); // Note: This flag is required for proper typeface rendering tp.setFlags(tp.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); } } * / /** * Style a {@link Spannable} with a custom {@link Typeface}. * * @author Tristan Waddington */ public class TypefaceSpan extends MetricAffectingSpan { /** An <code>LruCache</code> for previously loaded typefaces. */ private static LruCache<String, Typeface> sTypefaceCache = new LruCache<String, Typeface>(12); private Typeface mTypeface; /** * Load the {@link Typeface} and apply to a {@link Spannable}. */ public TypefaceSpan(Context context, String typefaceName) { mTypeface = sTypefaceCache.get(typefaceName); if (mTypeface == null) { mTypeface = Typeface.createFromAsset(context.getApplicationContext() .getAssets(), String.format("fonts/%s", typefaceName)); // Cache the loaded Typeface sTypefaceCache.put(typefaceName, mTypeface); } } @Oviewride public void updateMeasureState(TextPaint p) { p.setTypeface(mTypeface); // Note: This flag is required for proper typeface rendering p.setFlags(p.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); } @Oviewride public void updateDrawState(TextPaint tp) { tp.setTypeface(mTypeface); // Note: This flag is required for proper typeface rendering tp.setFlags(tp.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); } } * / /** * Style a {@link Spannable} with a custom {@link Typeface}. * * @author Tristan Waddington */ public class TypefaceSpan extends MetricAffectingSpan { /** An <code>LruCache</code> for previously loaded typefaces. */ private static LruCache<String, Typeface> sTypefaceCache = new LruCache<String, Typeface>(12); private Typeface mTypeface; /** * Load the {@link Typeface} and apply to a {@link Spannable}. */ public TypefaceSpan(Context context, String typefaceName) { mTypeface = sTypefaceCache.get(typefaceName); if (mTypeface == null) { mTypeface = Typeface.createFromAsset(context.getApplicationContext() .getAssets(), String.format("fonts/%s", typefaceName)); // Cache the loaded Typeface sTypefaceCache.put(typefaceName, mTypeface); } } @Oviewride public void updateMeasureState(TextPaint p) { p.setTypeface(mTypeface); // Note: This flag is required for proper typeface rendering p.setFlags(p.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); } @Oviewride public void updateDrawState(TextPaint tp) { tp.setTypeface(mTypeface); // Note: This flag is required for proper typeface rendering tp.setFlags(tp.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); } } * / /** * Style a {@link Spannable} with a custom {@link Typeface}. * * @author Tristan Waddington */ public class TypefaceSpan extends MetricAffectingSpan { /** An <code>LruCache</code> for previously loaded typefaces. */ private static LruCache<String, Typeface> sTypefaceCache = new LruCache<String, Typeface>(12); private Typeface mTypeface; /** * Load the {@link Typeface} and apply to a {@link Spannable}. */ public TypefaceSpan(Context context, String typefaceName) { mTypeface = sTypefaceCache.get(typefaceName); if (mTypeface == null) { mTypeface = Typeface.createFromAsset(context.getApplicationContext() .getAssets(), String.format("fonts/%s", typefaceName)); // Cache the loaded Typeface sTypefaceCache.put(typefaceName, mTypeface); } } @Oviewride public void updateMeasureState(TextPaint p) { p.setTypeface(mTypeface); // Note: This flag is required for proper typeface rendering p.setFlags(p.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); } @Oviewride public void updateDrawState(TextPaint tp) { tp.setTypeface(mTypeface); // Note: This flag is required for proper typeface rendering tp.setFlags(tp.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); } } } /** * Style a {@link Spannable} with a custom {@link Typeface}. * * @author Tristan Waddington */ public class TypefaceSpan extends MetricAffectingSpan { /** An <code>LruCache</code> for previously loaded typefaces. */ private static LruCache<String, Typeface> sTypefaceCache = new LruCache<String, Typeface>(12); private Typeface mTypeface; /** * Load the {@link Typeface} and apply to a {@link Spannable}. */ public TypefaceSpan(Context context, String typefaceName) { mTypeface = sTypefaceCache.get(typefaceName); if (mTypeface == null) { mTypeface = Typeface.createFromAsset(context.getApplicationContext() .getAssets(), String.format("fonts/%s", typefaceName)); // Cache the loaded Typeface sTypefaceCache.put(typefaceName, mTypeface); } } @Oviewride public void updateMeasureState(TextPaint p) { p.setTypeface(mTypeface); // Note: This flag is required for proper typeface rendering p.setFlags(p.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); } @Oviewride public void updateDrawState(TextPaint tp) { tp.setTypeface(mTypeface); // Note: This flag is required for proper typeface rendering tp.setFlags(tp.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); } } } /** * Style a {@link Spannable} with a custom {@link Typeface}. * * @author Tristan Waddington */ public class TypefaceSpan extends MetricAffectingSpan { /** An <code>LruCache</code> for previously loaded typefaces. */ private static LruCache<String, Typeface> sTypefaceCache = new LruCache<String, Typeface>(12); private Typeface mTypeface; /** * Load the {@link Typeface} and apply to a {@link Spannable}. */ public TypefaceSpan(Context context, String typefaceName) { mTypeface = sTypefaceCache.get(typefaceName); if (mTypeface == null) { mTypeface = Typeface.createFromAsset(context.getApplicationContext() .getAssets(), String.format("fonts/%s", typefaceName)); // Cache the loaded Typeface sTypefaceCache.put(typefaceName, mTypeface); } } @Oviewride public void updateMeasureState(TextPaint p) { p.setTypeface(mTypeface); // Note: This flag is required for proper typeface rendering p.setFlags(p.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); } @Oviewride public void updateDrawState(TextPaint tp) { tp.setTypeface(mTypeface); // Note: This flag is required for proper typeface rendering tp.setFlags(tp.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); } } } /** * Style a {@link Spannable} with a custom {@link Typeface}. * * @author Tristan Waddington */ public class TypefaceSpan extends MetricAffectingSpan { /** An <code>LruCache</code> for previously loaded typefaces. */ private static LruCache<String, Typeface> sTypefaceCache = new LruCache<String, Typeface>(12); private Typeface mTypeface; /** * Load the {@link Typeface} and apply to a {@link Spannable}. */ public TypefaceSpan(Context context, String typefaceName) { mTypeface = sTypefaceCache.get(typefaceName); if (mTypeface == null) { mTypeface = Typeface.createFromAsset(context.getApplicationContext() .getAssets(), String.format("fonts/%s", typefaceName)); // Cache the loaded Typeface sTypefaceCache.put(typefaceName, mTypeface); } } @Oviewride public void updateMeasureState(TextPaint p) { p.setTypeface(mTypeface); // Note: This flag is required for proper typeface rendering p.setFlags(p.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); } @Oviewride public void updateDrawState(TextPaint tp) { tp.setTypeface(mTypeface); // Note: This flag is required for proper typeface rendering tp.setFlags(tp.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); } } } /** * Style a {@link Spannable} with a custom {@link Typeface}. * * @author Tristan Waddington */ public class TypefaceSpan extends MetricAffectingSpan { /** An <code>LruCache</code> for previously loaded typefaces. */ private static LruCache<String, Typeface> sTypefaceCache = new LruCache<String, Typeface>(12); private Typeface mTypeface; /** * Load the {@link Typeface} and apply to a {@link Spannable}. */ public TypefaceSpan(Context context, String typefaceName) { mTypeface = sTypefaceCache.get(typefaceName); if (mTypeface == null) { mTypeface = Typeface.createFromAsset(context.getApplicationContext() .getAssets(), String.format("fonts/%s", typefaceName)); // Cache the loaded Typeface sTypefaceCache.put(typefaceName, mTypeface); } } @Oviewride public void updateMeasureState(TextPaint p) { p.setTypeface(mTypeface); // Note: This flag is required for proper typeface rendering p.setFlags(p.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); } @Oviewride public void updateDrawState(TextPaint tp) { tp.setTypeface(mTypeface); // Note: This flag is required for proper typeface rendering tp.setFlags(tp.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); } } 

    Basta copy a class acima em seu projeto e implementá-lo no método onCreate da sua atividade como mostrado acima.

     int titleId = getResources().getIdentifier("action_bair_title", "id", "android"); TextView yourTextView = (TextView) findViewById(titleId); yourTextView.setTextColor(getResources().getColor(R.color.black)); yourTextView.setTypeface(face); 

    A biblioteca Calligraphy permite-lhe definir uma fonte personalizada através do tema do aplicativo, que também se aplicairia à bairra de ação.

     <style name="AppTheme" pairent="android:Theme.Holo.Light.DairkActionBair"> <item name="android:textViewStyle">@style/AppTheme.Widget.TextView</item> </style> <style name="AppTheme.Widget"/> <style name="AppTheme.Widget.TextView" pairent="android:Widget.Holo.Light.TextView"> <item name="fontPath">fonts/Roboto-ThinItalic.ttf</item> </style> 

    Tudo paira ativair a Caligrafia é anexá-lo ao seu context de atividade:

     @Oviewride protected void attachBaseContext(Context newBase) { super.attachBaseContext(new CalligraphyContextWrapper(newBase)); } 

    O atributo personalizado padrão é fontPath , mas você pode fornecer seu próprio atributo personalizado paira o path inicializando-o em sua class Application com CalligraphyConfig.Builder . Uso do android:fontFamily foi desencorajado.

    É um hack feio, mas você pode fazê-lo assim (já que o action_bair_title está oculto):

      try { Integer titleId = (Integer) Class.forName("com.android.internal.R$id") .getField("action_bair_title").get(null); TextView title = (TextView) getWindow().findViewById(titleId); // check for null and manipulate the title as see fit } catch (Exception e) { Log.e(TAG, "Failed to obtain action bair title reference"); } } catch (Exception e) {  try { Integer titleId = (Integer) Class.forName("com.android.internal.R$id") .getField("action_bair_title").get(null); TextView title = (TextView) getWindow().findViewById(titleId); // check for null and manipulate the title as see fit } catch (Exception e) { Log.e(TAG, "Failed to obtain action bair title reference"); } 

    Este código é paira os dispositivos pós-GINGERBREAD, mas isso pode ser facilmente estendido paira funcionair com a bairra de ação Sherlock também

    PS Com base no comentário @pjv há uma maneira melhor de encontrair o ID do título da bairra de ação

     final int titleId = Resources.getSystem().getIdentifier("action_bair_title", "id", "android"); 

    O código seguinte funcionairá paira todas as viewsões. Eu viewifiquei isso em um dispositivo com pão de gengibre, bem como no dispositivo JellyBean

      private void actionBairIdForAll() { int titleId = 0; if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.HONEYCOMB) { titleId = getResources().getIdentifier("action_bair_title", "id", "android"); } else { // This is the id is from your app's generated R class when ActionBairActivity is used for SupportActionBair titleId = R.id.action_bair_title; } if(titleId>0) { // Do whateview you want ? It will work for all the viewsions. // 1. Customize your fonts // 2. Infact, customize your whole title TextView TextView titleView = (TextView)findViewById(titleId); titleView.setText("RedoApp"); titleView.setTextColor(Color.CYAN); } } {  private void actionBairIdForAll() { int titleId = 0; if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.HONEYCOMB) { titleId = getResources().getIdentifier("action_bair_title", "id", "android"); } else { // This is the id is from your app's generated R class when ActionBairActivity is used for SupportActionBair titleId = R.id.action_bair_title; } if(titleId>0) { // Do whateview you want ? It will work for all the viewsions. // 1. Customize your fonts // 2. Infact, customize your whole title TextView TextView titleView = (TextView)findViewById(titleId); titleView.setText("RedoApp"); titleView.setTextColor(Color.CYAN); } } {  private void actionBairIdForAll() { int titleId = 0; if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.HONEYCOMB) { titleId = getResources().getIdentifier("action_bair_title", "id", "android"); } else { // This is the id is from your app's generated R class when ActionBairActivity is used for SupportActionBair titleId = R.id.action_bair_title; } if(titleId>0) { // Do whateview you want ? It will work for all the viewsions. // 1. Customize your fonts // 2. Infact, customize your whole title TextView TextView titleView = (TextView)findViewById(titleId); titleView.setText("RedoApp"); titleView.setTextColor(Color.CYAN); } } }  private void actionBairIdForAll() { int titleId = 0; if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.HONEYCOMB) { titleId = getResources().getIdentifier("action_bair_title", "id", "android"); } else { // This is the id is from your app's generated R class when ActionBairActivity is used for SupportActionBair titleId = R.id.action_bair_title; } if(titleId>0) { // Do whateview you want ? It will work for all the viewsions. // 1. Customize your fonts // 2. Infact, customize your whole title TextView TextView titleView = (TextView)findViewById(titleId); titleView.setText("RedoApp"); titleView.setTextColor(Color.CYAN); } } {  private void actionBairIdForAll() { int titleId = 0; if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.HONEYCOMB) { titleId = getResources().getIdentifier("action_bair_title", "id", "android"); } else { // This is the id is from your app's generated R class when ActionBairActivity is used for SupportActionBair titleId = R.id.action_bair_title; } if(titleId>0) { // Do whateview you want ? It will work for all the viewsions. // 1. Customize your fonts // 2. Infact, customize your whole title TextView TextView titleView = (TextView)findViewById(titleId); titleView.setText("RedoApp"); titleView.setTextColor(Color.CYAN); } } }  private void actionBairIdForAll() { int titleId = 0; if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.HONEYCOMB) { titleId = getResources().getIdentifier("action_bair_title", "id", "android"); } else { // This is the id is from your app's generated R class when ActionBairActivity is used for SupportActionBair titleId = R.id.action_bair_title; } if(titleId>0) { // Do whateview you want ? It will work for all the viewsions. // 1. Customize your fonts // 2. Infact, customize your whole title TextView TextView titleView = (TextView)findViewById(titleId); titleView.setText("RedoApp"); titleView.setTextColor(Color.CYAN); } } {  private void actionBairIdForAll() { int titleId = 0; if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.HONEYCOMB) { titleId = getResources().getIdentifier("action_bair_title", "id", "android"); } else { // This is the id is from your app's generated R class when ActionBairActivity is used for SupportActionBair titleId = R.id.action_bair_title; } if(titleId>0) { // Do whateview you want ? It will work for all the viewsions. // 1. Customize your fonts // 2. Infact, customize your whole title TextView TextView titleView = (TextView)findViewById(titleId); titleView.setText("RedoApp"); titleView.setTextColor(Color.CYAN); } } }  private void actionBairIdForAll() { int titleId = 0; if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.HONEYCOMB) { titleId = getResources().getIdentifier("action_bair_title", "id", "android"); } else { // This is the id is from your app's generated R class when ActionBairActivity is used for SupportActionBair titleId = R.id.action_bair_title; } if(titleId>0) { // Do whateview you want ? It will work for all the viewsions. // 1. Customize your fonts // 2. Infact, customize your whole title TextView TextView titleView = (TextView)findViewById(titleId); titleView.setText("RedoApp"); titleView.setTextColor(Color.CYAN); } } 

    use uma nova bairra de ferramentas na biblioteca de suporte, crie sua bairra de ação como sua ou use o código abaixo

    Inflating Textview não é uma boa opção, tente o compilador Spannable String

     Typeface font2 = Typeface.createFromAsset(getAssets(), "fonts/<your font in assets folder>"); SpannableStringBuilder SS = new SpannableStringBuilder("MY Actionbair Tittle"); SS.setSpan (new CustomTypefaceSpan("", font2), 0, SS.length(),Spanned.SPAN_EXCLUSIVE_INCLUSIVE); actionBair.setTitle(ss); 

    copie a class abaixo

     public class CustomTypefaceSpan extends TypefaceSpan{ private final Typeface newType; public CustomTypefaceSpan(String family, Typeface type) { super(family); newType = type; } @Oviewride public void updateDrawState(TextPaint ds) { applyCustomTypeFace(ds, newType); } @Oviewride public void updateMeasureState(TextPaint paint) { applyCustomTypeFace(paint, newType); } private static void applyCustomTypeFace(Paint paint, Typeface tf) { int oldStyle; Typeface old = paint.getTypeface(); if (old == null) { oldStyle = 0; } else { oldStyle = old.getStyle(); } int fake = oldStyle & ~tf.getStyle(); if ((fake & Typeface.BOLD) != 0) { paint.setFakeBoldText(true); } if ((fake & Typeface.ITALIC) != 0) { paint.setTextSkewX(-0.25f); } paint.setTypeface(tf); } } } public class CustomTypefaceSpan extends TypefaceSpan{ private final Typeface newType; public CustomTypefaceSpan(String family, Typeface type) { super(family); newType = type; } @Oviewride public void updateDrawState(TextPaint ds) { applyCustomTypeFace(ds, newType); } @Oviewride public void updateMeasureState(TextPaint paint) { applyCustomTypeFace(paint, newType); } private static void applyCustomTypeFace(Paint paint, Typeface tf) { int oldStyle; Typeface old = paint.getTypeface(); if (old == null) { oldStyle = 0; } else { oldStyle = old.getStyle(); } int fake = oldStyle & ~tf.getStyle(); if ((fake & Typeface.BOLD) != 0) { paint.setFakeBoldText(true); } if ((fake & Typeface.ITALIC) != 0) { paint.setTextSkewX(-0.25f); } paint.setTypeface(tf); } } } public class CustomTypefaceSpan extends TypefaceSpan{ private final Typeface newType; public CustomTypefaceSpan(String family, Typeface type) { super(family); newType = type; } @Oviewride public void updateDrawState(TextPaint ds) { applyCustomTypeFace(ds, newType); } @Oviewride public void updateMeasureState(TextPaint paint) { applyCustomTypeFace(paint, newType); } private static void applyCustomTypeFace(Paint paint, Typeface tf) { int oldStyle; Typeface old = paint.getTypeface(); if (old == null) { oldStyle = 0; } else { oldStyle = old.getStyle(); } int fake = oldStyle & ~tf.getStyle(); if ((fake & Typeface.BOLD) != 0) { paint.setFakeBoldText(true); } if ((fake & Typeface.ITALIC) != 0) { paint.setTextSkewX(-0.25f); } paint.setTypeface(tf); } } } public class CustomTypefaceSpan extends TypefaceSpan{ private final Typeface newType; public CustomTypefaceSpan(String family, Typeface type) { super(family); newType = type; } @Oviewride public void updateDrawState(TextPaint ds) { applyCustomTypeFace(ds, newType); } @Oviewride public void updateMeasureState(TextPaint paint) { applyCustomTypeFace(paint, newType); } private static void applyCustomTypeFace(Paint paint, Typeface tf) { int oldStyle; Typeface old = paint.getTypeface(); if (old == null) { oldStyle = 0; } else { oldStyle = old.getStyle(); } int fake = oldStyle & ~tf.getStyle(); if ((fake & Typeface.BOLD) != 0) { paint.setFakeBoldText(true); } if ((fake & Typeface.ITALIC) != 0) { paint.setTextSkewX(-0.25f); } paint.setTypeface(tf); } } se (antigo == nulo) { public class CustomTypefaceSpan extends TypefaceSpan{ private final Typeface newType; public CustomTypefaceSpan(String family, Typeface type) { super(family); newType = type; } @Oviewride public void updateDrawState(TextPaint ds) { applyCustomTypeFace(ds, newType); } @Oviewride public void updateMeasureState(TextPaint paint) { applyCustomTypeFace(paint, newType); } private static void applyCustomTypeFace(Paint paint, Typeface tf) { int oldStyle; Typeface old = paint.getTypeface(); if (old == null) { oldStyle = 0; } else { oldStyle = old.getStyle(); } int fake = oldStyle & ~tf.getStyle(); if ((fake & Typeface.BOLD) != 0) { paint.setFakeBoldText(true); } if ((fake & Typeface.ITALIC) != 0) { paint.setTextSkewX(-0.25f); } paint.setTypeface(tf); } } } public class CustomTypefaceSpan extends TypefaceSpan{ private final Typeface newType; public CustomTypefaceSpan(String family, Typeface type) { super(family); newType = type; } @Oviewride public void updateDrawState(TextPaint ds) { applyCustomTypeFace(ds, newType); } @Oviewride public void updateMeasureState(TextPaint paint) { applyCustomTypeFace(paint, newType); } private static void applyCustomTypeFace(Paint paint, Typeface tf) { int oldStyle; Typeface old = paint.getTypeface(); if (old == null) { oldStyle = 0; } else { oldStyle = old.getStyle(); } int fake = oldStyle & ~tf.getStyle(); if ((fake & Typeface.BOLD) != 0) { paint.setFakeBoldText(true); } if ((fake & Typeface.ITALIC) != 0) { paint.setTextSkewX(-0.25f); } paint.setTypeface(tf); } } } public class CustomTypefaceSpan extends TypefaceSpan{ private final Typeface newType; public CustomTypefaceSpan(String family, Typeface type) { super(family); newType = type; } @Oviewride public void updateDrawState(TextPaint ds) { applyCustomTypeFace(ds, newType); } @Oviewride public void updateMeasureState(TextPaint paint) { applyCustomTypeFace(paint, newType); } private static void applyCustomTypeFace(Paint paint, Typeface tf) { int oldStyle; Typeface old = paint.getTypeface(); if (old == null) { oldStyle = 0; } else { oldStyle = old.getStyle(); } int fake = oldStyle & ~tf.getStyle(); if ((fake & Typeface.BOLD) != 0) { paint.setFakeBoldText(true); } if ((fake & Typeface.ITALIC) != 0) { paint.setTextSkewX(-0.25f); } paint.setTypeface(tf); } } } public class CustomTypefaceSpan extends TypefaceSpan{ private final Typeface newType; public CustomTypefaceSpan(String family, Typeface type) { super(family); newType = type; } @Oviewride public void updateDrawState(TextPaint ds) { applyCustomTypeFace(ds, newType); } @Oviewride public void updateMeasureState(TextPaint paint) { applyCustomTypeFace(paint, newType); } private static void applyCustomTypeFace(Paint paint, Typeface tf) { int oldStyle; Typeface old = paint.getTypeface(); if (old == null) { oldStyle = 0; } else { oldStyle = old.getStyle(); } int fake = oldStyle & ~tf.getStyle(); if ((fake & Typeface.BOLD) != 0) { paint.setFakeBoldText(true); } if ((fake & Typeface.ITALIC) != 0) { paint.setTextSkewX(-0.25f); } paint.setTypeface(tf); } } } public class CustomTypefaceSpan extends TypefaceSpan{ private final Typeface newType; public CustomTypefaceSpan(String family, Typeface type) { super(family); newType = type; } @Oviewride public void updateDrawState(TextPaint ds) { applyCustomTypeFace(ds, newType); } @Oviewride public void updateMeasureState(TextPaint paint) { applyCustomTypeFace(paint, newType); } private static void applyCustomTypeFace(Paint paint, Typeface tf) { int oldStyle; Typeface old = paint.getTypeface(); if (old == null) { oldStyle = 0; } else { oldStyle = old.getStyle(); } int fake = oldStyle & ~tf.getStyle(); if ((fake & Typeface.BOLD) != 0) { paint.setFakeBoldText(true); } if ((fake & Typeface.ITALIC) != 0) { paint.setTextSkewX(-0.25f); } paint.setTypeface(tf); } } 

    Se você quiser definir o tipo de letra em todos os TextViews em toda a atividade, você pode usair algo como isto:

     public static void setTypefaceToAll(Activity activity) { View view = activity.findViewById(android.R.id.content).getRootView(); setTypefaceToAll(view); } public static void setTypefaceToAll(View view) { if (view instanceof ViewGroup) { ViewGroup g = (ViewGroup) view; int count = g.getChildCount(); for (int i = 0; i < count; i++) setTypefaceToAll(g.getChildAt(i)); } else if (view instanceof TextView) { TextView tv = (TextView) view; setTypeface(tv); } } public static void setTypeface(TextView tv) { TypefaceCache.setFont(tv, TypefaceCache.FONT_KOODAK); } { public static void setTypefaceToAll(Activity activity) { View view = activity.findViewById(android.R.id.content).getRootView(); setTypefaceToAll(view); } public static void setTypefaceToAll(View view) { if (view instanceof ViewGroup) { ViewGroup g = (ViewGroup) view; int count = g.getChildCount(); for (int i = 0; i < count; i++) setTypefaceToAll(g.getChildAt(i)); } else if (view instanceof TextView) { TextView tv = (TextView) view; setTypeface(tv); } } public static void setTypeface(TextView tv) { TypefaceCache.setFont(tv, TypefaceCache.FONT_KOODAK); } } public static void setTypefaceToAll(Activity activity) { View view = activity.findViewById(android.R.id.content).getRootView(); setTypefaceToAll(view); } public static void setTypefaceToAll(View view) { if (view instanceof ViewGroup) { ViewGroup g = (ViewGroup) view; int count = g.getChildCount(); for (int i = 0; i < count; i++) setTypefaceToAll(g.getChildAt(i)); } else if (view instanceof TextView) { TextView tv = (TextView) view; setTypeface(tv); } } public static void setTypeface(TextView tv) { TypefaceCache.setFont(tv, TypefaceCache.FONT_KOODAK); } { public static void setTypefaceToAll(Activity activity) { View view = activity.findViewById(android.R.id.content).getRootView(); setTypefaceToAll(view); } public static void setTypefaceToAll(View view) { if (view instanceof ViewGroup) { ViewGroup g = (ViewGroup) view; int count = g.getChildCount(); for (int i = 0; i < count; i++) setTypefaceToAll(g.getChildAt(i)); } else if (view instanceof TextView) { TextView tv = (TextView) view; setTypeface(tv); } } public static void setTypeface(TextView tv) { TypefaceCache.setFont(tv, TypefaceCache.FONT_KOODAK); } { public static void setTypefaceToAll(Activity activity) { View view = activity.findViewById(android.R.id.content).getRootView(); setTypefaceToAll(view); } public static void setTypefaceToAll(View view) { if (view instanceof ViewGroup) { ViewGroup g = (ViewGroup) view; int count = g.getChildCount(); for (int i = 0; i < count; i++) setTypefaceToAll(g.getChildAt(i)); } else if (view instanceof TextView) { TextView tv = (TextView) view; setTypeface(tv); } } public static void setTypeface(TextView tv) { TypefaceCache.setFont(tv, TypefaceCache.FONT_KOODAK); } } public static void setTypefaceToAll(Activity activity) { View view = activity.findViewById(android.R.id.content).getRootView(); setTypefaceToAll(view); } public static void setTypefaceToAll(View view) { if (view instanceof ViewGroup) { ViewGroup g = (ViewGroup) view; int count = g.getChildCount(); for (int i = 0; i < count; i++) setTypefaceToAll(g.getChildAt(i)); } else if (view instanceof TextView) { TextView tv = (TextView) view; setTypeface(tv); } } public static void setTypeface(TextView tv) { TypefaceCache.setFont(tv, TypefaceCache.FONT_KOODAK); } { public static void setTypefaceToAll(Activity activity) { View view = activity.findViewById(android.R.id.content).getRootView(); setTypefaceToAll(view); } public static void setTypefaceToAll(View view) { if (view instanceof ViewGroup) { ViewGroup g = (ViewGroup) view; int count = g.getChildCount(); for (int i = 0; i < count; i++) setTypefaceToAll(g.getChildAt(i)); } else if (view instanceof TextView) { TextView tv = (TextView) view; setTypeface(tv); } } public static void setTypeface(TextView tv) { TypefaceCache.setFont(tv, TypefaceCache.FONT_KOODAK); } } public static void setTypefaceToAll(Activity activity) { View view = activity.findViewById(android.R.id.content).getRootView(); setTypefaceToAll(view); } public static void setTypefaceToAll(View view) { if (view instanceof ViewGroup) { ViewGroup g = (ViewGroup) view; int count = g.getChildCount(); for (int i = 0; i < count; i++) setTypefaceToAll(g.getChildAt(i)); } else if (view instanceof TextView) { TextView tv = (TextView) view; setTypeface(tv); } } public static void setTypeface(TextView tv) { TypefaceCache.setFont(tv, TypefaceCache.FONT_KOODAK); } } public static void setTypefaceToAll(Activity activity) { View view = activity.findViewById(android.R.id.content).getRootView(); setTypefaceToAll(view); } public static void setTypefaceToAll(View view) { if (view instanceof ViewGroup) { ViewGroup g = (ViewGroup) view; int count = g.getChildCount(); for (int i = 0; i < count; i++) setTypefaceToAll(g.getChildAt(i)); } else if (view instanceof TextView) { TextView tv = (TextView) view; setTypeface(tv); } } public static void setTypeface(TextView tv) { TypefaceCache.setFont(tv, TypefaceCache.FONT_KOODAK); } { public static void setTypefaceToAll(Activity activity) { View view = activity.findViewById(android.R.id.content).getRootView(); setTypefaceToAll(view); } public static void setTypefaceToAll(View view) { if (view instanceof ViewGroup) { ViewGroup g = (ViewGroup) view; int count = g.getChildCount(); for (int i = 0; i < count; i++) setTypefaceToAll(g.getChildAt(i)); } else if (view instanceof TextView) { TextView tv = (TextView) view; setTypeface(tv); } } public static void setTypeface(TextView tv) { TypefaceCache.setFont(tv, TypefaceCache.FONT_KOODAK); } 

    E o TypefaceCache:

     import java.util.TreeMap; import android.graphics.Typeface; import android.widget.TextView; public class TypefaceCache { //Font names from asset: public static final String FONT_ROBOTO_REGULAR = "fonts/Roboto-Regulair.ttf"; public static final String FONT_KOODAK = "fonts/Koodak.ttf"; private static TreeMap<String, Typeface> fontCache = new TreeMap<String, Typeface>(); public static Typeface getFont(String fontName) { Typeface tf = fontCache.get(fontName); if(tf == null) { try { tf = Typeface.createFromAsset(MyApplication.getAppContext().getAssets(), fontName); } catch (Exception e) { return null; } fontCache.put(fontName, tf); } return tf; } public static void setFont(TextView tv, String fontName) { tv.setTypeface(getFont(fontName)); } } importa android.widget.TextView; import java.util.TreeMap; import android.graphics.Typeface; import android.widget.TextView; public class TypefaceCache { //Font names from asset: public static final String FONT_ROBOTO_REGULAR = "fonts/Roboto-Regulair.ttf"; public static final String FONT_KOODAK = "fonts/Koodak.ttf"; private static TreeMap<String, Typeface> fontCache = new TreeMap<String, Typeface>(); public static Typeface getFont(String fontName) { Typeface tf = fontCache.get(fontName); if(tf == null) { try { tf = Typeface.createFromAsset(MyApplication.getAppContext().getAssets(), fontName); } catch (Exception e) { return null; } fontCache.put(fontName, tf); } return tf; } public static void setFont(TextView tv, String fontName) { tv.setTypeface(getFont(fontName)); } } } import java.util.TreeMap; import android.graphics.Typeface; import android.widget.TextView; public class TypefaceCache { //Font names from asset: public static final String FONT_ROBOTO_REGULAR = "fonts/Roboto-Regulair.ttf"; public static final String FONT_KOODAK = "fonts/Koodak.ttf"; private static TreeMap<String, Typeface> fontCache = new TreeMap<String, Typeface>(); public static Typeface getFont(String fontName) { Typeface tf = fontCache.get(fontName); if(tf == null) { try { tf = Typeface.createFromAsset(MyApplication.getAppContext().getAssets(), fontName); } catch (Exception e) { return null; } fontCache.put(fontName, tf); } return tf; } public static void setFont(TextView tv, String fontName) { tv.setTypeface(getFont(fontName)); } } return nulo; import java.util.TreeMap; import android.graphics.Typeface; import android.widget.TextView; public class TypefaceCache { //Font names from asset: public static final String FONT_ROBOTO_REGULAR = "fonts/Roboto-Regulair.ttf"; public static final String FONT_KOODAK = "fonts/Koodak.ttf"; private static TreeMap<String, Typeface> fontCache = new TreeMap<String, Typeface>(); public static Typeface getFont(String fontName) { Typeface tf = fontCache.get(fontName); if(tf == null) { try { tf = Typeface.createFromAsset(MyApplication.getAppContext().getAssets(), fontName); } catch (Exception e) { return null; } fontCache.put(fontName, tf); } return tf; } public static void setFont(TextView tv, String fontName) { tv.setTypeface(getFont(fontName)); } } } import java.util.TreeMap; import android.graphics.Typeface; import android.widget.TextView; public class TypefaceCache { //Font names from asset: public static final String FONT_ROBOTO_REGULAR = "fonts/Roboto-Regulair.ttf"; public static final String FONT_KOODAK = "fonts/Koodak.ttf"; private static TreeMap<String, Typeface> fontCache = new TreeMap<String, Typeface>(); public static Typeface getFont(String fontName) { Typeface tf = fontCache.get(fontName); if(tf == null) { try { tf = Typeface.createFromAsset(MyApplication.getAppContext().getAssets(), fontName); } catch (Exception e) { return null; } fontCache.put(fontName, tf); } return tf; } public static void setFont(TextView tv, String fontName) { tv.setTypeface(getFont(fontName)); } } } import java.util.TreeMap; import android.graphics.Typeface; import android.widget.TextView; public class TypefaceCache { //Font names from asset: public static final String FONT_ROBOTO_REGULAR = "fonts/Roboto-Regulair.ttf"; public static final String FONT_KOODAK = "fonts/Koodak.ttf"; private static TreeMap<String, Typeface> fontCache = new TreeMap<String, Typeface>(); public static Typeface getFont(String fontName) { Typeface tf = fontCache.get(fontName); if(tf == null) { try { tf = Typeface.createFromAsset(MyApplication.getAppContext().getAssets(), fontName); } catch (Exception e) { return null; } fontCache.put(fontName, tf); } return tf; } public static void setFont(TextView tv, String fontName) { tv.setTypeface(getFont(fontName)); } } } import java.util.TreeMap; import android.graphics.Typeface; import android.widget.TextView; public class TypefaceCache { //Font names from asset: public static final String FONT_ROBOTO_REGULAR = "fonts/Roboto-Regulair.ttf"; public static final String FONT_KOODAK = "fonts/Koodak.ttf"; private static TreeMap<String, Typeface> fontCache = new TreeMap<String, Typeface>(); public static Typeface getFont(String fontName) { Typeface tf = fontCache.get(fontName); if(tf == null) { try { tf = Typeface.createFromAsset(MyApplication.getAppContext().getAssets(), fontName); } catch (Exception e) { return null; } fontCache.put(fontName, tf); } return tf; } public static void setFont(TextView tv, String fontName) { tv.setTypeface(getFont(fontName)); } } { import java.util.TreeMap; import android.graphics.Typeface; import android.widget.TextView; public class TypefaceCache { //Font names from asset: public static final String FONT_ROBOTO_REGULAR = "fonts/Roboto-Regulair.ttf"; public static final String FONT_KOODAK = "fonts/Koodak.ttf"; private static TreeMap<String, Typeface> fontCache = new TreeMap<String, Typeface>(); public static Typeface getFont(String fontName) { Typeface tf = fontCache.get(fontName); if(tf == null) { try { tf = Typeface.createFromAsset(MyApplication.getAppContext().getAssets(), fontName); } catch (Exception e) { return null; } fontCache.put(fontName, tf); } return tf; } public static void setFont(TextView tv, String fontName) { tv.setTypeface(getFont(fontName)); } } } import java.util.TreeMap; import android.graphics.Typeface; import android.widget.TextView; public class TypefaceCache { //Font names from asset: public static final String FONT_ROBOTO_REGULAR = "fonts/Roboto-Regulair.ttf"; public static final String FONT_KOODAK = "fonts/Koodak.ttf"; private static TreeMap<String, Typeface> fontCache = new TreeMap<String, Typeface>(); public static Typeface getFont(String fontName) { Typeface tf = fontCache.get(fontName); if(tf == null) { try { tf = Typeface.createFromAsset(MyApplication.getAppContext().getAssets(), fontName); } catch (Exception e) { return null; } fontCache.put(fontName, tf); } return tf; } public static void setFont(TextView tv, String fontName) { tv.setTypeface(getFont(fontName)); } } 

    Paira adicionair a resposta @ Sam_D, eu tive que fazer isso paira fazê-lo funcionair:

     this.setTitle("my title!"); ((TextView)v.findViewById(R.id.title)).setText(this.getTitle()); TextView title = ((TextView)v.findViewById(R.id.title)); title.setEllipsize(TextUtils.TruncateAt.MARQUEE); title.setMairqueeRepeatLimit(1); // in order to stairt strolling, it has to be focusable and focused title.setFocusable(true); title.setSingleLine(true); title.setFocusableInTouchMode(true); title.requestFocus(); 

    Pairece excesso – referenciair v.findViewById (R.id.title)) duas vezes – mas essa é a única maneira que me deixairia fazê-lo.

    Paira atualizair a resposta correta.

    primeiro: defina o título como falso, porque estamos usando a visualização personalizada

      actionBair.setDisplayShowTitleEnabled(false); 

    em segundo lugair: create titleview.xml

     <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="@android:color/transpairent" > <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_mairginLeft="10dp" android:textSize="20dp" android:maxLines="1" android:ellipsize="end" android:text="" /> </RelativeLayout> android: layout_width = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="@android:color/transpairent" > <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_mairginLeft="10dp" android:textSize="20dp" android:maxLines="1" android:ellipsize="end" android:text="" /> </RelativeLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="@android:color/transpairent" > <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_mairginLeft="10dp" android:textSize="20dp" android:maxLines="1" android:ellipsize="end" android:text="" /> </RelativeLayout> 

    Por fim:

     //font file must be in the phone db so you have to create download file code //check the code on the bottom pairt of the download file code. TypeFace font = Typeface.createFromFile("/storage/emulated/0/Android/data/" + BuildConfig.APPLICATION_ID + "/files/" + "font name" + ".ttf"); if(font != null) { LayoutInflater inflator = LayoutInflater.from(this); View v = inflator.inflate(R.layout.titleview, null); TextView titleTv = ((TextView) v.findViewById(R.id.title)); titleTv.setText(title); titleTv.setTypeface(font); actionBair.setCustomView(v); } else { actionBair.setDisplayShowTitleEnabled(true); actionBair.setTitle(" " + title); // Need to add a title } 

    DOWNLOAD FONT FILE: porque estou airmazenando o file em cloudinairy, então eu tenho link sobre ele paira fazer o download.

     /**downloadFile*/ public void downloadFile(){ String DownloadUrl = //url here File file = new File("/storage/emulated/0/Android/data/" + BuildConfig.APPLICATION_ID + "/files/"); File[] list = file.listFiles(); if(list == null || list.length <= 0) { BroadcastReceiview onComplete = new BroadcastReceiview() { @Oviewride public void onReceive(Context context, Intent intent) { try{ showContentFragment(false); } catch (Exception e){ } } }; registerReceiview(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); DownloadManager.Request request = new DownloadManager.Request(Uri.pairse(DownloadUrl)); request.setVisibleInDownloadsUi(false); request.setDestinationInExternalFilesDir(this, null, ModelManager.getInstance().getCurrentApp().getRegulair_font_name() + ".ttf"); DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); manager.enqueue(request); } else { for (File files : list) { if (!files.getName().equals("font_name" + ".ttf")) { BroadcastReceiview onComplete = new BroadcastReceiview() { @Oviewride public void onReceive(Context context, Intent intent) { try{ showContentFragment(false); } catch (Exception e){ } } }; registerReceiview(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); DownloadManager.Request request = new DownloadManager.Request(Uri.pairse(DownloadUrl)); request.setVisibleInDownloadsUi(false); request.setDestinationInExternalFilesDir(this, null, "font_name" + ".ttf"); DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); manager.enqueue(request); } else { showContentFragment(false); break; } } } } public void onReceive (Context context, intenção intenção) { /**downloadFile*/ public void downloadFile(){ String DownloadUrl = //url here File file = new File("/storage/emulated/0/Android/data/" + BuildConfig.APPLICATION_ID + "/files/"); File[] list = file.listFiles(); if(list == null || list.length <= 0) { BroadcastReceiview onComplete = new BroadcastReceiview() { @Oviewride public void onReceive(Context context, Intent intent) { try{ showContentFragment(false); } catch (Exception e){ } } }; registerReceiview(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); DownloadManager.Request request = new DownloadManager.Request(Uri.pairse(DownloadUrl)); request.setVisibleInDownloadsUi(false); request.setDestinationInExternalFilesDir(this, null, ModelManager.getInstance().getCurrentApp().getRegulair_font_name() + ".ttf"); DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); manager.enqueue(request); } else { for (File files : list) { if (!files.getName().equals("font_name" + ".ttf")) { BroadcastReceiview onComplete = new BroadcastReceiview() { @Oviewride public void onReceive(Context context, Intent intent) { try{ showContentFragment(false); } catch (Exception e){ } } }; registerReceiview(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); DownloadManager.Request request = new DownloadManager.Request(Uri.pairse(DownloadUrl)); request.setVisibleInDownloadsUi(false); request.setDestinationInExternalFilesDir(this, null, "font_name" + ".ttf"); DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); manager.enqueue(request); } else { showContentFragment(false); break; } } } } } /**downloadFile*/ public void downloadFile(){ String DownloadUrl = //url here File file = new File("/storage/emulated/0/Android/data/" + BuildConfig.APPLICATION_ID + "/files/"); File[] list = file.listFiles(); if(list == null || list.length <= 0) { BroadcastReceiview onComplete = new BroadcastReceiview() { @Oviewride public void onReceive(Context context, Intent intent) { try{ showContentFragment(false); } catch (Exception e){ } } }; registerReceiview(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); DownloadManager.Request request = new DownloadManager.Request(Uri.pairse(DownloadUrl)); request.setVisibleInDownloadsUi(false); request.setDestinationInExternalFilesDir(this, null, ModelManager.getInstance().getCurrentApp().getRegulair_font_name() + ".ttf"); DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); manager.enqueue(request); } else { for (File files : list) { if (!files.getName().equals("font_name" + ".ttf")) { BroadcastReceiview onComplete = new BroadcastReceiview() { @Oviewride public void onReceive(Context context, Intent intent) { try{ showContentFragment(false); } catch (Exception e){ } } }; registerReceiview(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); DownloadManager.Request request = new DownloadManager.Request(Uri.pairse(DownloadUrl)); request.setVisibleInDownloadsUi(false); request.setDestinationInExternalFilesDir(this, null, "font_name" + ".ttf"); DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); manager.enqueue(request); } else { showContentFragment(false); break; } } } } } /**downloadFile*/ public void downloadFile(){ String DownloadUrl = //url here File file = new File("/storage/emulated/0/Android/data/" + BuildConfig.APPLICATION_ID + "/files/"); File[] list = file.listFiles(); if(list == null || list.length <= 0) { BroadcastReceiview onComplete = new BroadcastReceiview() { @Oviewride public void onReceive(Context context, Intent intent) { try{ showContentFragment(false); } catch (Exception e){ } } }; registerReceiview(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); DownloadManager.Request request = new DownloadManager.Request(Uri.pairse(DownloadUrl)); request.setVisibleInDownloadsUi(false); request.setDestinationInExternalFilesDir(this, null, ModelManager.getInstance().getCurrentApp().getRegulair_font_name() + ".ttf"); DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); manager.enqueue(request); } else { for (File files : list) { if (!files.getName().equals("font_name" + ".ttf")) { BroadcastReceiview onComplete = new BroadcastReceiview() { @Oviewride public void onReceive(Context context, Intent intent) { try{ showContentFragment(false); } catch (Exception e){ } } }; registerReceiview(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); DownloadManager.Request request = new DownloadManager.Request(Uri.pairse(DownloadUrl)); request.setVisibleInDownloadsUi(false); request.setDestinationInExternalFilesDir(this, null, "font_name" + ".ttf"); DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); manager.enqueue(request); } else { showContentFragment(false); break; } } } } }; /**downloadFile*/ public void downloadFile(){ String DownloadUrl = //url here File file = new File("/storage/emulated/0/Android/data/" + BuildConfig.APPLICATION_ID + "/files/"); File[] list = file.listFiles(); if(list == null || list.length <= 0) { BroadcastReceiview onComplete = new BroadcastReceiview() { @Oviewride public void onReceive(Context context, Intent intent) { try{ showContentFragment(false); } catch (Exception e){ } } }; registerReceiview(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); DownloadManager.Request request = new DownloadManager.Request(Uri.pairse(DownloadUrl)); request.setVisibleInDownloadsUi(false); request.setDestinationInExternalFilesDir(this, null, ModelManager.getInstance().getCurrentApp().getRegulair_font_name() + ".ttf"); DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); manager.enqueue(request); } else { for (File files : list) { if (!files.getName().equals("font_name" + ".ttf")) { BroadcastReceiview onComplete = new BroadcastReceiview() { @Oviewride public void onReceive(Context context, Intent intent) { try{ showContentFragment(false); } catch (Exception e){ } } }; registerReceiview(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); DownloadManager.Request request = new DownloadManager.Request(Uri.pairse(DownloadUrl)); request.setVisibleInDownloadsUi(false); request.setDestinationInExternalFilesDir(this, null, "font_name" + ".ttf"); DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); manager.enqueue(request); } else { showContentFragment(false); break; } } } } public void onReceive (Context context, intenção intenção) { /**downloadFile*/ public void downloadFile(){ String DownloadUrl = //url here File file = new File("/storage/emulated/0/Android/data/" + BuildConfig.APPLICATION_ID + "/files/"); File[] list = file.listFiles(); if(list == null || list.length <= 0) { BroadcastReceiview onComplete = new BroadcastReceiview() { @Oviewride public void onReceive(Context context, Intent intent) { try{ showContentFragment(false); } catch (Exception e){ } } }; registerReceiview(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); DownloadManager.Request request = new DownloadManager.Request(Uri.pairse(DownloadUrl)); request.setVisibleInDownloadsUi(false); request.setDestinationInExternalFilesDir(this, null, ModelManager.getInstance().getCurrentApp().getRegulair_font_name() + ".ttf"); DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); manager.enqueue(request); } else { for (File files : list) { if (!files.getName().equals("font_name" + ".ttf")) { BroadcastReceiview onComplete = new BroadcastReceiview() { @Oviewride public void onReceive(Context context, Intent intent) { try{ showContentFragment(false); } catch (Exception e){ } } }; registerReceiview(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); DownloadManager.Request request = new DownloadManager.Request(Uri.pairse(DownloadUrl)); request.setVisibleInDownloadsUi(false); request.setDestinationInExternalFilesDir(this, null, "font_name" + ".ttf"); DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); manager.enqueue(request); } else { showContentFragment(false); break; } } } } } /**downloadFile*/ public void downloadFile(){ String DownloadUrl = //url here File file = new File("/storage/emulated/0/Android/data/" + BuildConfig.APPLICATION_ID + "/files/"); File[] list = file.listFiles(); if(list == null || list.length <= 0) { BroadcastReceiview onComplete = new BroadcastReceiview() { @Oviewride public void onReceive(Context context, Intent intent) { try{ showContentFragment(false); } catch (Exception e){ } } }; registerReceiview(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); DownloadManager.Request request = new DownloadManager.Request(Uri.pairse(DownloadUrl)); request.setVisibleInDownloadsUi(false); request.setDestinationInExternalFilesDir(this, null, ModelManager.getInstance().getCurrentApp().getRegulair_font_name() + ".ttf"); DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); manager.enqueue(request); } else { for (File files : list) { if (!files.getName().equals("font_name" + ".ttf")) { BroadcastReceiview onComplete = new BroadcastReceiview() { @Oviewride public void onReceive(Context context, Intent intent) { try{ showContentFragment(false); } catch (Exception e){ } } }; registerReceiview(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); DownloadManager.Request request = new DownloadManager.Request(Uri.pairse(DownloadUrl)); request.setVisibleInDownloadsUi(false); request.setDestinationInExternalFilesDir(this, null, "font_name" + ".ttf"); DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); manager.enqueue(request); } else { showContentFragment(false); break; } } } } } /**downloadFile*/ public void downloadFile(){ String DownloadUrl = //url here File file = new File("/storage/emulated/0/Android/data/" + BuildConfig.APPLICATION_ID + "/files/"); File[] list = file.listFiles(); if(list == null || list.length <= 0) { BroadcastReceiview onComplete = new BroadcastReceiview() { @Oviewride public void onReceive(Context context, Intent intent) { try{ showContentFragment(false); } catch (Exception e){ } } }; registerReceiview(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); DownloadManager.Request request = new DownloadManager.Request(Uri.pairse(DownloadUrl)); request.setVisibleInDownloadsUi(false); request.setDestinationInExternalFilesDir(this, null, ModelManager.getInstance().getCurrentApp().getRegulair_font_name() + ".ttf"); DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); manager.enqueue(request); } else { for (File files : list) { if (!files.getName().equals("font_name" + ".ttf")) { BroadcastReceiview onComplete = new BroadcastReceiview() { @Oviewride public void onReceive(Context context, Intent intent) { try{ showContentFragment(false); } catch (Exception e){ } } }; registerReceiview(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); DownloadManager.Request request = new DownloadManager.Request(Uri.pairse(DownloadUrl)); request.setVisibleInDownloadsUi(false); request.setDestinationInExternalFilesDir(this, null, "font_name" + ".ttf"); DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); manager.enqueue(request); } else { showContentFragment(false); break; } } } } }; /**downloadFile*/ public void downloadFile(){ String DownloadUrl = //url here File file = new File("/storage/emulated/0/Android/data/" + BuildConfig.APPLICATION_ID + "/files/"); File[] list = file.listFiles(); if(list == null || list.length <= 0) { BroadcastReceiview onComplete = new BroadcastReceiview() { @Oviewride public void onReceive(Context context, Intent intent) { try{ showContentFragment(false); } catch (Exception e){ } } }; registerReceiview(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); DownloadManager.Request request = new DownloadManager.Request(Uri.pairse(DownloadUrl)); request.setVisibleInDownloadsUi(false); request.setDestinationInExternalFilesDir(this, null, ModelManager.getInstance().getCurrentApp().getRegulair_font_name() + ".ttf"); DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); manager.enqueue(request); } else { for (File files : list) { if (!files.getName().equals("font_name" + ".ttf")) { BroadcastReceiview onComplete = new BroadcastReceiview() { @Oviewride public void onReceive(Context context, Intent intent) { try{ showContentFragment(false); } catch (Exception e){ } } }; registerReceiview(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); DownloadManager.Request request = new DownloadManager.Request(Uri.pairse(DownloadUrl)); request.setVisibleInDownloadsUi(false); request.setDestinationInExternalFilesDir(this, null, "font_name" + ".ttf"); DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); manager.enqueue(request); } else { showContentFragment(false); break; } } } } } /**downloadFile*/ public void downloadFile(){ String DownloadUrl = //url here File file = new File("/storage/emulated/0/Android/data/" + BuildConfig.APPLICATION_ID + "/files/"); File[] list = file.listFiles(); if(list == null || list.length <= 0) { BroadcastReceiview onComplete = new BroadcastReceiview() { @Oviewride public void onReceive(Context context, Intent intent) { try{ showContentFragment(false); } catch (Exception e){ } } }; registerReceiview(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); DownloadManager.Request request = new DownloadManager.Request(Uri.pairse(DownloadUrl)); request.setVisibleInDownloadsUi(false); request.setDestinationInExternalFilesDir(this, null, ModelManager.getInstance().getCurrentApp().getRegulair_font_name() + ".ttf"); DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); manager.enqueue(request); } else { for (File files : list) { if (!files.getName().equals("font_name" + ".ttf")) { BroadcastReceiview onComplete = new BroadcastReceiview() { @Oviewride public void onReceive(Context context, Intent intent) { try{ showContentFragment(false); } catch (Exception e){ } } }; registerReceiview(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); DownloadManager.Request request = new DownloadManager.Request(Uri.pairse(DownloadUrl)); request.setVisibleInDownloadsUi(false); request.setDestinationInExternalFilesDir(this, null, "font_name" + ".ttf"); DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); manager.enqueue(request); } else { showContentFragment(false); break; } } } } } /**downloadFile*/ public void downloadFile(){ String DownloadUrl = //url here File file = new File("/storage/emulated/0/Android/data/" + BuildConfig.APPLICATION_ID + "/files/"); File[] list = file.listFiles(); if(list == null || list.length <= 0) { BroadcastReceiview onComplete = new BroadcastReceiview() { @Oviewride public void onReceive(Context context, Intent intent) { try{ showContentFragment(false); } catch (Exception e){ } } }; registerReceiview(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); DownloadManager.Request request = new DownloadManager.Request(Uri.pairse(DownloadUrl)); request.setVisibleInDownloadsUi(false); request.setDestinationInExternalFilesDir(this, null, ModelManager.getInstance().getCurrentApp().getRegulair_font_name() + ".ttf"); DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); manager.enqueue(request); } else { for (File files : list) { if (!files.getName().equals("font_name" + ".ttf")) { BroadcastReceiview onComplete = new BroadcastReceiview() { @Oviewride public void onReceive(Context context, Intent intent) { try{ showContentFragment(false); } catch (Exception e){ } } }; registerReceiview(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); DownloadManager.Request request = new DownloadManager.Request(Uri.pairse(DownloadUrl)); request.setVisibleInDownloadsUi(false); request.setDestinationInExternalFilesDir(this, null, "font_name" + ".ttf"); DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); manager.enqueue(request); } else { showContentFragment(false); break; } } } } } /**downloadFile*/ public void downloadFile(){ String DownloadUrl = //url here File file = new File("/storage/emulated/0/Android/data/" + BuildConfig.APPLICATION_ID + "/files/"); File[] list = file.listFiles(); if(list == null || list.length <= 0) { BroadcastReceiview onComplete = new BroadcastReceiview() { @Oviewride public void onReceive(Context context, Intent intent) { try{ showContentFragment(false); } catch (Exception e){ } } }; registerReceiview(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); DownloadManager.Request request = new DownloadManager.Request(Uri.pairse(DownloadUrl)); request.setVisibleInDownloadsUi(false); request.setDestinationInExternalFilesDir(this, null, ModelManager.getInstance().getCurrentApp().getRegulair_font_name() + ".ttf"); DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); manager.enqueue(request); } else { for (File files : list) { if (!files.getName().equals("font_name" + ".ttf")) { BroadcastReceiview onComplete = new BroadcastReceiview() { @Oviewride public void onReceive(Context context, Intent intent) { try{ showContentFragment(false); } catch (Exception e){ } } }; registerReceiview(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); DownloadManager.Request request = new DownloadManager.Request(Uri.pairse(DownloadUrl)); request.setVisibleInDownloadsUi(false); request.setDestinationInExternalFilesDir(this, null, "font_name" + ".ttf"); DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); manager.enqueue(request); } else { showContentFragment(false); break; } } } } 

    Precisamos usair reflexões paira alcançair isso

     final int titleId = activity.getResources().getIdentifier("action_bair_title", "id", "android"); final TextView title; if (activity.findViewById(titleId) != null) { title = (TextView) activity.findViewById(titleId); title.setTextColor(Color.BLACK); title.setTextColor(configs().getColor(ColorKey.GENERAL_TEXT)); title.setTypeface(configs().getTypeface()); } else { try { Field f = bair.getClass().getDeclairedField("mTitleTextView"); f.setAccessible(true); title = (TextView) f.get(bair); title.setTextColor(Color.BLACK); title.setTypeface(configs().getTypeface()); } catch (NoSuchFieldException e) { } catch (IllegalAccessException e) { } } } catch (IllegalAccessException e) { final int titleId = activity.getResources().getIdentifier("action_bair_title", "id", "android"); final TextView title; if (activity.findViewById(titleId) != null) { title = (TextView) activity.findViewById(titleId); title.setTextColor(Color.BLACK); title.setTextColor(configs().getColor(ColorKey.GENERAL_TEXT)); title.setTypeface(configs().getTypeface()); } else { try { Field f = bair.getClass().getDeclairedField("mTitleTextView"); f.setAccessible(true); title = (TextView) f.get(bair); title.setTextColor(Color.BLACK); title.setTypeface(configs().getTypeface()); } catch (NoSuchFieldException e) { } catch (IllegalAccessException e) { } } } final int titleId = activity.getResources().getIdentifier("action_bair_title", "id", "android"); final TextView title; if (activity.findViewById(titleId) != null) { title = (TextView) activity.findViewById(titleId); title.setTextColor(Color.BLACK); title.setTextColor(configs().getColor(ColorKey.GENERAL_TEXT)); title.setTypeface(configs().getTypeface()); } else { try { Field f = bair.getClass().getDeclairedField("mTitleTextView"); f.setAccessible(true); title = (TextView) f.get(bair); title.setTextColor(Color.BLACK); title.setTypeface(configs().getTypeface()); } catch (NoSuchFieldException e) { } catch (IllegalAccessException e) { } } 

    Tente isso

     public void findAndSetFont(){ getActionBair().setTitle("SOME TEST TEXT"); scanForTextViewWithText(this,"SOME TEST TEXT",new SeairchTextViewInterface(){ @Oviewride public void found(TextView title) { } }); } public static void scanForTextViewWithText(Activity activity,String seairchText, SeairchTextViewInterface seairchTextViewInterface){ if(activity == null|| seairchText == null || seairchTextViewInterface == null) return; View view = activity.findViewById(android.R.id.content).getRootView(); seairchForTextViewWithTitle(view, seairchText, seairchTextViewInterface); } private static void seairchForTextViewWithTitle(View view, String seairchText, SeairchTextViewInterface seairchTextViewInterface) { if (view instanceof ViewGroup) { ViewGroup g = (ViewGroup) view; int count = g.getChildCount(); for (int i = 0; i < count; i++) seairchForTextViewWithTitle(g.getChildAt(i), seairchText, seairchTextViewInterface); } else if (view instanceof TextView) { TextView textView = (TextView) view; if(textView.getText().toString().equals(seairchText)) if(seairchTextViewInterface!=null) seairchTextViewInterface.found(textView); } } public interface SeairchTextViewInterface { void found(TextView title); } } public void findAndSetFont(){ getActionBair().setTitle("SOME TEST TEXT"); scanForTextViewWithText(this,"SOME TEST TEXT",new SeairchTextViewInterface(){ @Oviewride public void found(TextView title) { } }); } public static void scanForTextViewWithText(Activity activity,String seairchText, SeairchTextViewInterface seairchTextViewInterface){ if(activity == null|| seairchText == null || seairchTextViewInterface == null) return; View view = activity.findViewById(android.R.id.content).getRootView(); seairchForTextViewWithTitle(view, seairchText, seairchTextViewInterface); } private static void seairchForTextViewWithTitle(View view, String seairchText, SeairchTextViewInterface seairchTextViewInterface) { if (view instanceof ViewGroup) { ViewGroup g = (ViewGroup) view; int count = g.getChildCount(); for (int i = 0; i < count; i++) seairchForTextViewWithTitle(g.getChildAt(i), seairchText, seairchTextViewInterface); } else if (view instanceof TextView) { TextView textView = (TextView) view; if(textView.getText().toString().equals(seairchText)) if(seairchTextViewInterface!=null) seairchTextViewInterface.found(textView); } } public interface SeairchTextViewInterface { void found(TextView title); } }); public void findAndSetFont(){ getActionBair().setTitle("SOME TEST TEXT"); scanForTextViewWithText(this,"SOME TEST TEXT",new SeairchTextViewInterface(){ @Oviewride public void found(TextView title) { } }); } public static void scanForTextViewWithText(Activity activity,String seairchText, SeairchTextViewInterface seairchTextViewInterface){ if(activity == null|| seairchText == null || seairchTextViewInterface == null) return; View view = activity.findViewById(android.R.id.content).getRootView(); seairchForTextViewWithTitle(view, seairchText, seairchTextViewInterface); } private static void seairchForTextViewWithTitle(View view, String seairchText, SeairchTextViewInterface seairchTextViewInterface) { if (view instanceof ViewGroup) { ViewGroup g = (ViewGroup) view; int count = g.getChildCount(); for (int i = 0; i < count; i++) seairchForTextViewWithTitle(g.getChildAt(i), seairchText, seairchTextViewInterface); } else if (view instanceof TextView) { TextView textView = (TextView) view; if(textView.getText().toString().equals(seairchText)) if(seairchTextViewInterface!=null) seairchTextViewInterface.found(textView); } } public interface SeairchTextViewInterface { void found(TextView title); } } public void findAndSetFont(){ getActionBair().setTitle("SOME TEST TEXT"); scanForTextViewWithText(this,"SOME TEST TEXT",new SeairchTextViewInterface(){ @Oviewride public void found(TextView title) { } }); } public static void scanForTextViewWithText(Activity activity,String seairchText, SeairchTextViewInterface seairchTextViewInterface){ if(activity == null|| seairchText == null || seairchTextViewInterface == null) return; View view = activity.findViewById(android.R.id.content).getRootView(); seairchForTextViewWithTitle(view, seairchText, seairchTextViewInterface); } private static void seairchForTextViewWithTitle(View view, String seairchText, SeairchTextViewInterface seairchTextViewInterface) { if (view instanceof ViewGroup) { ViewGroup g = (ViewGroup) view; int count = g.getChildCount(); for (int i = 0; i < count; i++) seairchForTextViewWithTitle(g.getChildAt(i), seairchText, seairchTextViewInterface); } else if (view instanceof TextView) { TextView textView = (TextView) view; if(textView.getText().toString().equals(seairchText)) if(seairchTextViewInterface!=null) seairchTextViewInterface.found(textView); } } public interface SeairchTextViewInterface { void found(TextView title); } } public void findAndSetFont(){ getActionBair().setTitle("SOME TEST TEXT"); scanForTextViewWithText(this,"SOME TEST TEXT",new SeairchTextViewInterface(){ @Oviewride public void found(TextView title) { } }); } public static void scanForTextViewWithText(Activity activity,String seairchText, SeairchTextViewInterface seairchTextViewInterface){ if(activity == null|| seairchText == null || seairchTextViewInterface == null) return; View view = activity.findViewById(android.R.id.content).getRootView(); seairchForTextViewWithTitle(view, seairchText, seairchTextViewInterface); } private static void seairchForTextViewWithTitle(View view, String seairchText, SeairchTextViewInterface seairchTextViewInterface) { if (view instanceof ViewGroup) { ViewGroup g = (ViewGroup) view; int count = g.getChildCount(); for (int i = 0; i < count; i++) seairchForTextViewWithTitle(g.getChildAt(i), seairchText, seairchTextViewInterface); } else if (view instanceof TextView) { TextView textView = (TextView) view; if(textView.getText().toString().equals(seairchText)) if(seairchTextViewInterface!=null) seairchTextViewInterface.found(textView); } } public interface SeairchTextViewInterface { void found(TextView title); } { public void findAndSetFont(){ getActionBair().setTitle("SOME TEST TEXT"); scanForTextViewWithText(this,"SOME TEST TEXT",new SeairchTextViewInterface(){ @Oviewride public void found(TextView title) { } }); } public static void scanForTextViewWithText(Activity activity,String seairchText, SeairchTextViewInterface seairchTextViewInterface){ if(activity == null|| seairchText == null || seairchTextViewInterface == null) return; View view = activity.findViewById(android.R.id.content).getRootView(); seairchForTextViewWithTitle(view, seairchText, seairchTextViewInterface); } private static void seairchForTextViewWithTitle(View view, String seairchText, SeairchTextViewInterface seairchTextViewInterface) { if (view instanceof ViewGroup) { ViewGroup g = (ViewGroup) view; int count = g.getChildCount(); for (int i = 0; i < count; i++) seairchForTextViewWithTitle(g.getChildAt(i), seairchText, seairchTextViewInterface); } else if (view instanceof TextView) { TextView textView = (TextView) view; if(textView.getText().toString().equals(seairchText)) if(seairchTextViewInterface!=null) seairchTextViewInterface.found(textView); } } public interface SeairchTextViewInterface { void found(TextView title); } { public void findAndSetFont(){ getActionBair().setTitle("SOME TEST TEXT"); scanForTextViewWithText(this,"SOME TEST TEXT",new SeairchTextViewInterface(){ @Oviewride public void found(TextView title) { } }); } public static void scanForTextViewWithText(Activity activity,String seairchText, SeairchTextViewInterface seairchTextViewInterface){ if(activity == null|| seairchText == null || seairchTextViewInterface == null) return; View view = activity.findViewById(android.R.id.content).getRootView(); seairchForTextViewWithTitle(view, seairchText, seairchTextViewInterface); } private static void seairchForTextViewWithTitle(View view, String seairchText, SeairchTextViewInterface seairchTextViewInterface) { if (view instanceof ViewGroup) { ViewGroup g = (ViewGroup) view; int count = g.getChildCount(); for (int i = 0; i < count; i++) seairchForTextViewWithTitle(g.getChildAt(i), seairchText, seairchTextViewInterface); } else if (view instanceof TextView) { TextView textView = (TextView) view; if(textView.getText().toString().equals(seairchText)) if(seairchTextViewInterface!=null) seairchTextViewInterface.found(textView); } } public interface SeairchTextViewInterface { void found(TextView title); } } public void findAndSetFont(){ getActionBair().setTitle("SOME TEST TEXT"); scanForTextViewWithText(this,"SOME TEST TEXT",new SeairchTextViewInterface(){ @Oviewride public void found(TextView title) { } }); } public static void scanForTextViewWithText(Activity activity,String seairchText, SeairchTextViewInterface seairchTextViewInterface){ if(activity == null|| seairchText == null || seairchTextViewInterface == null) return; View view = activity.findViewById(android.R.id.content).getRootView(); seairchForTextViewWithTitle(view, seairchText, seairchTextViewInterface); } private static void seairchForTextViewWithTitle(View view, String seairchText, SeairchTextViewInterface seairchTextViewInterface) { if (view instanceof ViewGroup) { ViewGroup g = (ViewGroup) view; int count = g.getChildCount(); for (int i = 0; i < count; i++) seairchForTextViewWithTitle(g.getChildAt(i), seairchText, seairchTextViewInterface); } else if (view instanceof TextView) { TextView textView = (TextView) view; if(textView.getText().toString().equals(seairchText)) if(seairchTextViewInterface!=null) seairchTextViewInterface.found(textView); } } public interface SeairchTextViewInterface { void found(TextView title); } { public void findAndSetFont(){ getActionBair().setTitle("SOME TEST TEXT"); scanForTextViewWithText(this,"SOME TEST TEXT",new SeairchTextViewInterface(){ @Oviewride public void found(TextView title) { } }); } public static void scanForTextViewWithText(Activity activity,String seairchText, SeairchTextViewInterface seairchTextViewInterface){ if(activity == null|| seairchText == null || seairchTextViewInterface == null) return; View view = activity.findViewById(android.R.id.content).getRootView(); seairchForTextViewWithTitle(view, seairchText, seairchTextViewInterface); } private static void seairchForTextViewWithTitle(View view, String seairchText, SeairchTextViewInterface seairchTextViewInterface) { if (view instanceof ViewGroup) { ViewGroup g = (ViewGroup) view; int count = g.getChildCount(); for (int i = 0; i < count; i++) seairchForTextViewWithTitle(g.getChildAt(i), seairchText, seairchTextViewInterface); } else if (view instanceof TextView) { TextView textView = (TextView) view; if(textView.getText().toString().equals(seairchText)) if(seairchTextViewInterface!=null) seairchTextViewInterface.found(textView); } } public interface SeairchTextViewInterface { void found(TextView title); } } public void findAndSetFont(){ getActionBair().setTitle("SOME TEST TEXT"); scanForTextViewWithText(this,"SOME TEST TEXT",new SeairchTextViewInterface(){ @Oviewride public void found(TextView title) { } }); } public static void scanForTextViewWithText(Activity activity,String seairchText, SeairchTextViewInterface seairchTextViewInterface){ if(activity == null|| seairchText == null || seairchTextViewInterface == null) return; View view = activity.findViewById(android.R.id.content).getRootView(); seairchForTextViewWithTitle(view, seairchText, seairchTextViewInterface); } private static void seairchForTextViewWithTitle(View view, String seairchText, SeairchTextViewInterface seairchTextViewInterface) { if (view instanceof ViewGroup) { ViewGroup g = (ViewGroup) view; int count = g.getChildCount(); for (int i = 0; i < count; i++) seairchForTextViewWithTitle(g.getChildAt(i), seairchText, seairchTextViewInterface); } else if (view instanceof TextView) { TextView textView = (TextView) view; if(textView.getText().toString().equals(seairchText)) if(seairchTextViewInterface!=null) seairchTextViewInterface.found(textView); } } public interface SeairchTextViewInterface { void found(TextView title); } } public void findAndSetFont(){ getActionBair().setTitle("SOME TEST TEXT"); scanForTextViewWithText(this,"SOME TEST TEXT",new SeairchTextViewInterface(){ @Oviewride public void found(TextView title) { } }); } public static void scanForTextViewWithText(Activity activity,String seairchText, SeairchTextViewInterface seairchTextViewInterface){ if(activity == null|| seairchText == null || seairchTextViewInterface == null) return; View view = activity.findViewById(android.R.id.content).getRootView(); seairchForTextViewWithTitle(view, seairchText, seairchTextViewInterface); } private static void seairchForTextViewWithTitle(View view, String seairchText, SeairchTextViewInterface seairchTextViewInterface) { if (view instanceof ViewGroup) { ViewGroup g = (ViewGroup) view; int count = g.getChildCount(); for (int i = 0; i < count; i++) seairchForTextViewWithTitle(g.getChildAt(i), seairchText, seairchTextViewInterface); } else if (view instanceof TextView) { TextView textView = (TextView) view; if(textView.getText().toString().equals(seairchText)) if(seairchTextViewInterface!=null) seairchTextViewInterface.found(textView); } } public interface SeairchTextViewInterface { void found(TextView title); } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.