How to reduce the tab bar height and display in bottom

前端 未结 8 720
长情又很酷
长情又很酷 2021-02-02 04:42

can anybody tell how to reduce the height of tab bar and display tab bar in bottom

Thanks

8条回答
  •  温柔的废话
    2021-02-02 05:06

    Add the following method to your class that extends TabActivity

     public void addNewTab(Context context, String title, int height){
         TabHost tabHost = getTabHost();  // The activity TabHost
         Intent intent = new Intent().setClass(context, HelloTabsActivity.class);
         TabHost.TabSpec spec = tabHost.newTabSpec(title.toLowerCase()).setIndicator(title).setContent(intent);
         tabHost.addTab(spec);
         int totalTabs = tabHost.getTabWidget().getChildCount();
         ((RelativeLayout)tabHost.getTabWidget().getChildTabViewAt(totalTabs-1)).removeViewAt(0);
         ((TextView)((RelativeLayout)tabHost.getTabWidget().getChildTabViewAt(totalTabs-1)).getChildAt(0)).setHeight(30);
         tabHost.getTabWidget().getChildAt(totalTabs-1).getLayoutParams().height = height;
     }
    

    then call it like this addNewTab(this, "tab title", 30);

提交回复
热议问题