Note that there are some explanatory texts on larger screens.

plurals
  1. POChange Typeface All Fonts Android is not work
    text
    copied!<p>i'm learing how to change all fonts in android, but it's seem not work, just one changed textview, not all..</p> <p>this my code</p> <pre><code> public class AndroidTypefaceUtility { AndroidTypefaceUtility() { } public static void setFont(Context context, ViewGroup group) { Typeface tf = Typeface.createFromAsset(context.getAssets(), "fonts/OpenSans-Light.ttf"); int count = group.getChildCount(); View v; for(int i = 0; i &lt; count; i++) { v = group.getChildAt(i); if(v instanceof TextView || v instanceof Button || v instanceof EditText/*etc.*/) ((TextView)v).setTypeface(tf); else if(v instanceof ViewGroup) setFont(context, (ViewGroup)v); } } } </code></pre> <p>this implement code change all font</p> <pre><code> public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout_tab); ViewGroup root = (ViewGroup)findViewById(R.id.myrootlayout); AndroidTypefaceUtility.setFont(getApplicationContext(),root); } </code></pre> <p><strong>update</strong></p> <p>and this my xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#ffffff" android:id="@+id/myrootlayout" &gt; &lt;ListView android:id="@+id/menu_content_menulist" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="8dp" android:background="#d0000000" android:cacheColorHint="@android:color/transparent" android:divider="@null" android:scrollbars="none" android:listSelector="@null"/&gt; &lt;RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"&gt; &lt;com.smart.tangsel.side_menu_scroll.ScrollerLinearLayout android:id="@+id/menu_content_side_slide_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"&gt; &lt;TabHost android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center_vertical" android:gravity="center" &gt; &lt;LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/content_tab" android:orientation="vertical" android:background="@drawable/bg_app" &gt; &lt;include layout="@layout/layout_action_bar" /&gt; &lt;RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@null" android:orientation="vertical" &gt; &lt;FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@null" android:layout_above="@android:id/tabs"/&gt; &lt;TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" android:tabStripLeft="@drawable/tabstrip" android:tabStripRight="@drawable/tabstrip" android:soundEffectsEnabled="false" android:layout_alignParentBottom="true" /&gt; &lt;/RelativeLayout&gt; &lt;!-- &lt;include layout="@layout/footer_layout" /&gt; --&gt; &lt;/LinearLayout&gt; &lt;/TabHost&gt; &lt;/com.smart.tangsel.side_menu_scroll.ScrollerLinearLayout&gt; &lt;/RelativeLayout&gt;&lt;/RelativeLayout&gt; </code></pre> <p>anybody help me ? there my code is wrong ? thanks.. sorry for my english</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload