android - how to give equal width to all tabs? -


enter image description here hello please tell me why on landscape not acquiring equal width in portrait mode ?? there way provide equal width tabs in portrait mode.

i

landscape potrait

enter image description here

here code ..in portrait taking equal width on landscape not taking equal width why ?

here code

import android.app.actionbar; import android.app.fragmenttransaction; import android.os.bundle; import android.support.v4.app.fragmentactivity; import android.support.v4.view.viewpager;  public class mainactivity extends fragmentactivity implements actionbar.tablistener {    actionbar actionbar;     viewpager viewpager;     pageadapter pageadapter;      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);         viewpager = (viewpager) findviewbyid(r.id.pager);         pageadapter =new pageadapter(getsupportfragmentmanager());         viewpager.setadapter(pageadapter);          actionbar = getactionbar();          actionbar.setnavigationmode(actionbar.navigation_mode_tabs);         actionbar.addtab(actionbar.newtab().settext("tab1").settablistener(this));         actionbar.addtab(actionbar.newtab().settext("tab2").settablistener(this));         actionbar.addtab(actionbar.newtab().settext("tab3").settablistener(this));          viewpager.setonpagechangelistener(new viewpager.onpagechangelistener() {             @override             public void onpagescrolled(int i, float v, int i1) {              }              @override             public void onpageselected(int i) {             actionbar.setselectednavigationitem(i);             }              @override             public void onpagescrollstatechanged(int i) {              }         });       }       @override     public void ontabselected(actionbar.tab tab, fragmenttransaction ft) {          viewpager.setcurrentitem(tab.getposition());      }      @override     public void ontabunselected(actionbar.tab tab, fragmenttransaction ft) {      }      @override     public void ontabreselected(actionbar.tab tab, fragmenttransaction ft) {      } } 

adapter

import android.support.v4.app.fragment; import android.support.v4.app.fragmentmanager; import android.support.v4.app.fragmentpageradapter;   public class pageadapter extends fragmentpageradapter{     public pageadapter(fragmentmanager fm) {         super(fm);     }      @override     public fragment getitem(int i) {         switch (i){              case 0:                 return new fragmentone();             case 1:                 return  new fragmenttwo();             case 2:                 return  new fragmentthree();             default:                 break;          }         return null;     }      @override     public int getcount() {         return 3;     } } 


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -