3

I have created 3 tabs . But when i switch between tabs the height of tab indicator is very small,it comes like a thin line over tabs.I have not seen any post that gives me solution of this problem.All of them are about how to change the colour of tab indicator.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_ACTION_BAR);
    try {

        setContentView(R.layout.activity_main);
        ActionBar bar = getActionBar();

        Log.d("In Tab Activity", bar.toString());
        bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        Tab tab1 = bar.newTab();
        tab1.setText("Contacts");
        tab1.setTabListener(this);
        bar.addTab(tab1);




        Tab tab2 = bar.newTab();
        tab2.setText("Messages");
        tab2.setCustomView(TabUtils.renderTabView(this, R.string.tab_invitations, R.drawable.ic_add_alert_black_24dp, 5));
        tab2.setTabListener(this);
        bar.addTab(tab2);


        Tab tab3 = bar.newTab();
        tab3.setText("History");
        tab3.setTabListener(this);
        bar.addTab(tab3);

        webView = (WebView) findViewById(R.id.webPage);
        jSInterface = new AndroidJSInterface(this);
        webView.addJavascriptInterface(jSInterface, "AndroidJSInterface");

        webView.loadUrl("file:///android_asset/HybridPage2.html", null);

        /*
         * Fragment main = new MainFragment(); FragmentTransaction ft =
         * getFragmentManager().beginTransaction();
         * ft.replace(R.id.content_frame, main);
         * ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
         * ft.addToBackStack(null); ft.commit();
         */
    } catch (Exception e) {
        Log.d("Exception is", e.getMessage());
    }
}
Loren
  • 320
  • 1
  • 10
  • 25

2 Answers2

6

you can specify the tab indicator height by app:tabIndicatorHeight=".." in your xml file under TabLayout.

xujan24
  • 61
  • 1
  • 1
-1

Use New design library and refer following code.You can change TabLayout width to change height of TAB.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <android.support.v7.widget.Toolbar
        android:id="@+id/tab_toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/accent_material_light" />

    <android.support.design.widget.TabLayout
        android:id="@+id/tablayout"
        android:layout_width="match_parent"
        android:background="@color/accent_material_dark"
        android:layout_height="200dp" />

</android.support.design.widget.AppBarLayout>

Hardik Bambhania
  • 1,732
  • 15
  • 25
  • 3
    I dont want to change height of Tab. I want to change height of TAB INDICATOR which comes when we click on tabs. – Loren Aug 03 '15 at 10:00