0

I have a Vision tab with vision icon etc..,I want to increase the Font Size ,any one help?

Here My Code:

TabSpec vision = tabHost.newTabSpec("Vision");
        vision.setIndicator("Vision",
                getResources().getDrawable(R.drawable.visionicon));
String
  • 3,660
  • 10
  • 43
  • 66
  • Maybe this link can help you. Check it out. http://stackoverflow.com/questions/5788971/how-to-change-the-font-size-of-tabhost-in-android – Dhaval Oct 23 '13 at 09:56

3 Answers3

1

You can customize and use to increase text size of TabHost.See this tutorial

http://joshclemm.com/blog/?p=136

Shadow
  • 6,864
  • 6
  • 44
  • 93
1

For you tabspec dont set text add view like below then set font size to that view..

    TextView textView=new TextView(getApplicationContext());
    textView.setText("Vision");
    textView.setTextSize(10);
    TabSpec setContent = tabHost.newTabSpec(tag).setIndicator(textView);

Here i am coding one method here change layout as you like..

/**
 * Used to create tabview object and setting parameters
 * 
 * @param context
 * @param text
 * @return
 */
private View createTabView(final Context context, final String text) {
    View view = LayoutInflater.from(context).inflate(R.layout.tab_layout,
            null);
    Button _button = (Button) view.findViewById(R.id.tabText);
    _button.setText(text);
    _button.setTypeface(SmartLockUtils.getApplicationTypeFace(),
            Typeface.BOLD);
    return view;
}
kalyan pvs
  • 14,486
  • 4
  • 41
  • 59
1

For setting custom Layout for your Tabs :

First design a layout for the image & text to be passed named "tabs_bg":

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabsLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical" >

<ImageView
    android:id="@+id/tabs_image"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:scaleType="fitXY" />

<TextView
    android:id="@+id/tabs_tv"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal" />
</LinearLayout>

Next you need to add this method in your TabActivity :

/***** Method for Custom Tabs *****/
private static View createTabView(final Context context, final Drawable image, final String text) {
    View tab_view = LayoutInflater.from(context).inflate(R.layout.tabs_bg, null);
    ImageView img = (ImageView) tab_view.findViewById(R.id.tabs_image);
    img.setImageDrawable(image);
    TextView txt_text = (TextView) tab_view.findViewById(R.id.tabs_tv);
    txt_badge.setText(text);
    return tab_view;
}

Next in your TabActivity you need to Setup Your Tabs by using this code :

 TabHost.addTab(TabHost.newTabSpec("Tab1").setIndicator(createTabView(TabHost.getContext(),
            getResources().getDrawable(R.drawable.tab1_image), "Tab_Name")), Tab1.class, null);
arshu
  • 11,805
  • 3
  • 23
  • 21