How to change size of tabs

前端 未结 1 1369
醉酒成梦
醉酒成梦 2020-12-22 11:26

Actually i have created a tab in my app.here there are three tabs..but thing is that i am not able to manage style in the tabsan morevere i want size of one tab larger than

相关标签:
1条回答
  • 2020-12-22 11:53

    Here the code for changing the size of tab

     Display display = getWindowManager().getDefaultDisplay();
            int width = display.getWidth();
    
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    
           TabHost mTabHost = getTabHost();
    
           mTabHost.addTab(mTabHost.newTabSpec("tab_test1")
                   .setIndicator((""),getResources().getDrawable(R.drawable.mzl_05))
             .setContent(new Intent(this, NearBy.class)));
           mTabHost.addTab(mTabHost.newTabSpec("tab_test2")
                   .setIndicator((""),getResources().getDrawable(R.drawable.mzl_08))
             .setContent(new Intent(this, SearchBy.class)));
                   mTabHost.setCurrentTab(0);
                   mTabHost.getTabWidget().getChildAt(0).setLayoutParams(new
                     LinearLayout.LayoutParams((width/2)-2,50));
              mTabHost.getTabWidget().getChildAt(1).setLayoutParams(new
                         LinearLayout.LayoutParams((width/2)-2,50));
    

    I hope it is help full to you.

    0 讨论(0)
提交回复
热议问题