How to reduce the tab bar height and display in bottom

前端 未结 8 830
长情又很酷
长情又很酷 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:21

    You could either

    • Build your own tab using a TableLayout at the bottom of the screen - which gives you quite a lot of flexibility

    or

    • Modify use the existing TabHost/TabWidget - works in principle but I don't know how to reduce the tab bar height. Works like that:

    Layout file main.xml:

    
    
        
            
            
                
                    
                    
                
                
                    
                    
                
                
                    
                    
                
                
            
        
    
    

    Source code of your activity, in this case StartActivity.java

    import android.app.Activity;
    import android.os.Bundle;
    import android.widget.TabHost;
    import android.widget.TabHost.TabSpec;
    
    public class StartActivity extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
            TabHost tab_host = (TabHost) findViewById(R.id.tab_host);
            tab_host.setup();
    
            TabSpec tabspec1 = tab_host.newTabSpec("TAB_1");
            tabspec1.setIndicator("Tab 1");
            tabspec1.setContent(R.id.first_tab);
            tab_host.addTab(tabspec1);
    
            TabSpec tabspec2 = tab_host.newTabSpec("TAB_2");
            tabspec2.setIndicator("Tab 2");
            tabspec2.setContent(R.id.second_tab);
            tab_host.addTab(tabspec2);
    
            TabSpec tabspec3 = tab_host.newTabSpec("TAB_3");
            tabspec3.setIndicator("Tab 3");
            tabspec3.setContent(R.id.third_tab);
            tab_host.addTab(tabspec3);
    
            tab_host.setCurrentTab(0);
        }
    }
    

    Turns out to look like:

    alt text

提交回复
热议问题