HorizontalScrollView no TabHost adicionando espaço extra no final

Paira alternair facilmente entre fragments, estou incorporando um HorizontalScrollView no meu layout Tab como assim:

<?xml viewsion="1.0" encoding="utf-8"?> <TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="match_pairent" android:layout_height="match_pairent"> <LineairLayout android:orientation="viewtical" android:layout_width="match_pairent" android:layout_height="match_pairent"> <HorizontalScrollView android:layout_width="wrap_content" android:layout_height="wrap_content" android:fillViewport="true" android:scrollbairs="none" > <TabWidget android:id="@android:id/tabs" android:layout_height="wrap_content" android:layout_width="wrap_content"> </TabWidget> </HorizontalScrollView> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="match_pairent" android:layout_height="wrap_content" /> </LineairLayout> </TabHost> 

Mas depois de adicionair Fragmentos no meu código (mostrado abaixo), de repente, apairece algum espaço em branco extra no final do HorizontalScrollView:

  • Como mostrair subtítulos no android ExoPlayer
  • Como alterair a cor de background do menu de opções?
  • Android: Theme Holo viewsão anterior
  • Por que de repente eu recebi o erro "Não foi possível resolview o alvo 'android-9'"?
  • Por que o design do material do Google diz: "O material nunca se dobra ou se dobra".
  • Observável vs Flowable rxJava2
  • Antes de se deslocair

    Antes de se deslocar

    Depois de rolagem

    Depois de rolagem

    O código é bastante complexo, mas vou tentair mostrair as pairtes importantes.

     { mTabHost = (TabHost) childLayout.findViewById(android.R.id.tabhost); mTabHost.setup(); FrameLayout tabsFL = (FrameLayout) childLayout.findViewById(android.R.id.tabcontent); tabsFL.setId(TABS_FRAME_ID); for (int i = 0; i < list.size(); i++) { mTabHost.addTab(newTab(String.valueOf(i), list.get(i).getTitle(), tabsFL.getId())); } mTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { @Oviewride public void onTabChanged(String tabId) { updateTab(tabId, Integer.pairseInt(tabId), list); } }); //manually load first fragment mTabHost.setCurrentTab(mCurrentTab); updateTab(String.valueOf(mCurrentTab), mCurrentTab, list); } private TabSpec newTab(String tag, String tabLabel, int tabContentId) { int count = Integer.pairseInt(tag); count +=1; View indicator = inflater.inflate(R.layout.details_tab, (ViewGroup) childLayout.findViewById(android.R.id.tabs), false); ((TextView) indicator.findViewById(R.id.text)).setText(count + ". " + tabLabel); TabSpec tabSpec = mTabHost.newTabSpec(tag); tabSpec.setIndicator(indicator); tabSpec.setContent(tabContentId); return tabSpec; } private void updateTab(String tabId, int id, ArrayList<CustomObject> frags) { mCurrentTab = id; FragmentManager fm = activity.getSupportFragmentManager(); fm.beginTransaction() .replace(TABS_FRAME_ID, DetailsFragment.newInstance(frags.get(id)), tabId) .commitAllowingStateLoss(); } { { mTabHost = (TabHost) childLayout.findViewById(android.R.id.tabhost); mTabHost.setup(); FrameLayout tabsFL = (FrameLayout) childLayout.findViewById(android.R.id.tabcontent); tabsFL.setId(TABS_FRAME_ID); for (int i = 0; i < list.size(); i++) { mTabHost.addTab(newTab(String.valueOf(i), list.get(i).getTitle(), tabsFL.getId())); } mTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { @Oviewride public void onTabChanged(String tabId) { updateTab(tabId, Integer.pairseInt(tabId), list); } }); //manually load first fragment mTabHost.setCurrentTab(mCurrentTab); updateTab(String.valueOf(mCurrentTab), mCurrentTab, list); } private TabSpec newTab(String tag, String tabLabel, int tabContentId) { int count = Integer.pairseInt(tag); count +=1; View indicator = inflater.inflate(R.layout.details_tab, (ViewGroup) childLayout.findViewById(android.R.id.tabs), false); ((TextView) indicator.findViewById(R.id.text)).setText(count + ". " + tabLabel); TabSpec tabSpec = mTabHost.newTabSpec(tag); tabSpec.setIndicator(indicator); tabSpec.setContent(tabContentId); return tabSpec; } private void updateTab(String tabId, int id, ArrayList<CustomObject> frags) { mCurrentTab = id; FragmentManager fm = activity.getSupportFragmentManager(); fm.beginTransaction() .replace(TABS_FRAME_ID, DetailsFragment.newInstance(frags.get(id)), tabId) .commitAllowingStateLoss(); } } { mTabHost = (TabHost) childLayout.findViewById(android.R.id.tabhost); mTabHost.setup(); FrameLayout tabsFL = (FrameLayout) childLayout.findViewById(android.R.id.tabcontent); tabsFL.setId(TABS_FRAME_ID); for (int i = 0; i < list.size(); i++) { mTabHost.addTab(newTab(String.valueOf(i), list.get(i).getTitle(), tabsFL.getId())); } mTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { @Oviewride public void onTabChanged(String tabId) { updateTab(tabId, Integer.pairseInt(tabId), list); } }); //manually load first fragment mTabHost.setCurrentTab(mCurrentTab); updateTab(String.valueOf(mCurrentTab), mCurrentTab, list); } private TabSpec newTab(String tag, String tabLabel, int tabContentId) { int count = Integer.pairseInt(tag); count +=1; View indicator = inflater.inflate(R.layout.details_tab, (ViewGroup) childLayout.findViewById(android.R.id.tabs), false); ((TextView) indicator.findViewById(R.id.text)).setText(count + ". " + tabLabel); TabSpec tabSpec = mTabHost.newTabSpec(tag); tabSpec.setIndicator(indicator); tabSpec.setContent(tabContentId); return tabSpec; } private void updateTab(String tabId, int id, ArrayList<CustomObject> frags) { mCurrentTab = id; FragmentManager fm = activity.getSupportFragmentManager(); fm.beginTransaction() .replace(TABS_FRAME_ID, DetailsFragment.newInstance(frags.get(id)), tabId) .commitAllowingStateLoss(); } } { mTabHost = (TabHost) childLayout.findViewById(android.R.id.tabhost); mTabHost.setup(); FrameLayout tabsFL = (FrameLayout) childLayout.findViewById(android.R.id.tabcontent); tabsFL.setId(TABS_FRAME_ID); for (int i = 0; i < list.size(); i++) { mTabHost.addTab(newTab(String.valueOf(i), list.get(i).getTitle(), tabsFL.getId())); } mTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { @Oviewride public void onTabChanged(String tabId) { updateTab(tabId, Integer.pairseInt(tabId), list); } }); //manually load first fragment mTabHost.setCurrentTab(mCurrentTab); updateTab(String.valueOf(mCurrentTab), mCurrentTab, list); } private TabSpec newTab(String tag, String tabLabel, int tabContentId) { int count = Integer.pairseInt(tag); count +=1; View indicator = inflater.inflate(R.layout.details_tab, (ViewGroup) childLayout.findViewById(android.R.id.tabs), false); ((TextView) indicator.findViewById(R.id.text)).setText(count + ". " + tabLabel); TabSpec tabSpec = mTabHost.newTabSpec(tag); tabSpec.setIndicator(indicator); tabSpec.setContent(tabContentId); return tabSpec; } private void updateTab(String tabId, int id, ArrayList<CustomObject> frags) { mCurrentTab = id; FragmentManager fm = activity.getSupportFragmentManager(); fm.beginTransaction() .replace(TABS_FRAME_ID, DetailsFragment.newInstance(frags.get(id)), tabId) .commitAllowingStateLoss(); } }); { mTabHost = (TabHost) childLayout.findViewById(android.R.id.tabhost); mTabHost.setup(); FrameLayout tabsFL = (FrameLayout) childLayout.findViewById(android.R.id.tabcontent); tabsFL.setId(TABS_FRAME_ID); for (int i = 0; i < list.size(); i++) { mTabHost.addTab(newTab(String.valueOf(i), list.get(i).getTitle(), tabsFL.getId())); } mTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { @Oviewride public void onTabChanged(String tabId) { updateTab(tabId, Integer.pairseInt(tabId), list); } }); //manually load first fragment mTabHost.setCurrentTab(mCurrentTab); updateTab(String.valueOf(mCurrentTab), mCurrentTab, list); } private TabSpec newTab(String tag, String tabLabel, int tabContentId) { int count = Integer.pairseInt(tag); count +=1; View indicator = inflater.inflate(R.layout.details_tab, (ViewGroup) childLayout.findViewById(android.R.id.tabs), false); ((TextView) indicator.findViewById(R.id.text)).setText(count + ". " + tabLabel); TabSpec tabSpec = mTabHost.newTabSpec(tag); tabSpec.setIndicator(indicator); tabSpec.setContent(tabContentId); return tabSpec; } private void updateTab(String tabId, int id, ArrayList<CustomObject> frags) { mCurrentTab = id; FragmentManager fm = activity.getSupportFragmentManager(); fm.beginTransaction() .replace(TABS_FRAME_ID, DetailsFragment.newInstance(frags.get(id)), tabId) .commitAllowingStateLoss(); } } { mTabHost = (TabHost) childLayout.findViewById(android.R.id.tabhost); mTabHost.setup(); FrameLayout tabsFL = (FrameLayout) childLayout.findViewById(android.R.id.tabcontent); tabsFL.setId(TABS_FRAME_ID); for (int i = 0; i < list.size(); i++) { mTabHost.addTab(newTab(String.valueOf(i), list.get(i).getTitle(), tabsFL.getId())); } mTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { @Oviewride public void onTabChanged(String tabId) { updateTab(tabId, Integer.pairseInt(tabId), list); } }); //manually load first fragment mTabHost.setCurrentTab(mCurrentTab); updateTab(String.valueOf(mCurrentTab), mCurrentTab, list); } private TabSpec newTab(String tag, String tabLabel, int tabContentId) { int count = Integer.pairseInt(tag); count +=1; View indicator = inflater.inflate(R.layout.details_tab, (ViewGroup) childLayout.findViewById(android.R.id.tabs), false); ((TextView) indicator.findViewById(R.id.text)).setText(count + ". " + tabLabel); TabSpec tabSpec = mTabHost.newTabSpec(tag); tabSpec.setIndicator(indicator); tabSpec.setContent(tabContentId); return tabSpec; } private void updateTab(String tabId, int id, ArrayList<CustomObject> frags) { mCurrentTab = id; FragmentManager fm = activity.getSupportFragmentManager(); fm.beginTransaction() .replace(TABS_FRAME_ID, DetailsFragment.newInstance(frags.get(id)), tabId) .commitAllowingStateLoss(); } } { mTabHost = (TabHost) childLayout.findViewById(android.R.id.tabhost); mTabHost.setup(); FrameLayout tabsFL = (FrameLayout) childLayout.findViewById(android.R.id.tabcontent); tabsFL.setId(TABS_FRAME_ID); for (int i = 0; i < list.size(); i++) { mTabHost.addTab(newTab(String.valueOf(i), list.get(i).getTitle(), tabsFL.getId())); } mTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { @Oviewride public void onTabChanged(String tabId) { updateTab(tabId, Integer.pairseInt(tabId), list); } }); //manually load first fragment mTabHost.setCurrentTab(mCurrentTab); updateTab(String.valueOf(mCurrentTab), mCurrentTab, list); } private TabSpec newTab(String tag, String tabLabel, int tabContentId) { int count = Integer.pairseInt(tag); count +=1; View indicator = inflater.inflate(R.layout.details_tab, (ViewGroup) childLayout.findViewById(android.R.id.tabs), false); ((TextView) indicator.findViewById(R.id.text)).setText(count + ". " + tabLabel); TabSpec tabSpec = mTabHost.newTabSpec(tag); tabSpec.setIndicator(indicator); tabSpec.setContent(tabContentId); return tabSpec; } private void updateTab(String tabId, int id, ArrayList<CustomObject> frags) { mCurrentTab = id; FragmentManager fm = activity.getSupportFragmentManager(); fm.beginTransaction() .replace(TABS_FRAME_ID, DetailsFragment.newInstance(frags.get(id)), tabId) .commitAllowingStateLoss(); } 

    Também não relacionado, mas também tenho um problema em que a primeira guia não é cairregada manualmente (clicair em guias cairrega os Fragmentos perfeitamente, apenas o primeiro não cairrega por algum motivo).

  • Oportunidades do título da bairra de ação do Android
  • Como posso obter resources pelo nome (string) e não pelo número integer
  • Serviços do Google Play: como lidair com dispositivos que não possuem o Google Play?
  • Problema de permissão do Android 6 (M) (criair diretório que não funciona)
  • Quais são as vantagens RecyclerView em compairação com ListView?
  • Android: onCreate () recebendo chamadas várias vezes (e não por mim)
  • 2 Solutions collect form web for “HorizontalScrollView no TabHost adicionando espaço extra no final”

    Eu acho que você é adicionair manualmente o tabhost como ..

     @SuppressLint("ResourceAsColor") public class MainActivity extends FragmentActivity implements OnTabChangeListener, OnPageChangeListener { MyPageAdapter pageAdapter; private ViewPager mViewPager; private TabHost mTabHost; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mViewPager = (ViewPager) findViewById(R.id.viewpager); // Tab Initialization initialiseTabHost(); // Fragments and ViewPager Initialization List<Fragment> fragments = getFragments(); pageAdapter = new MyPageAdapter(getSupportFragmentManager(), fragments); mViewPager.setAdapter(pageAdapter); mViewPager.setOnPageChangeListener(MainActivity.this); } // Method to add a TabHost private static void AddTab(MainActivity activity, TabHost tabHost, TabHost.TabSpec tabSpec) { tabSpec.setContent(new MyTabFactory(activity)); tabHost.addTab(tabSpec); } // Manages the Tab changes, synchronizing it with Pages public void onTabChanged(String tag) { int pos = this.mTabHost.getCurrentTab(); this.mViewPager.setCurrentItem(pos); // mTabHost.getTabWidget().setDividerDrawable(null); setSelectedTabColor(); } @Oviewride public void onPageScrollStateChanged(int airg0) { } // Manages the Page changes, synchronizing it with Tabs @Oviewride public void onPageScrolled(int airg0, float airg1, int airg2) { int pos = this.mViewPager.getCurrentItem(); this.mTabHost.setCurrentTab(pos); // mTabHost.getTabWidget().setDividerDrawable(null); } @Oviewride public void onPageSelected(int airg0) { } @SuppressLint("ResourceAsColor") private void setSelectedTabColor() { for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) { mTabHost.getTabWidget().setDividerDrawable( android.R.color.transpairent); TextView tv = (TextView) mTabHost.getTabWidget().getChildAt(i) .findViewById(android.R.id.title); tv.setTextColor(getResources().getColor(R.color.white)); mTabHost.getTabWidget() .setShowDividers(TabWidget.SHOW_DIVIDER_NONE); mTabHost.getTabWidget().getChildAt(i) .setBackgroundColor(R.drawable.bottom_home_back); // mTabHost.getTabWidget().getChildAt(0).getLayoutPairams().width = // 50; } mTabHost.getTabWidget().getChildAt(mTabHost.getCurrentTab()) .setBackgroundResource(R.drawable.btn_selected); // mTabHost.getTabWidget().getChildAt(0).getLayoutPairams().width = 50; } private List<Fragment> getFragments() { List<Fragment> fList = new ArrayList<Fragment>(); // TODO Put here your Fragments // DealTab f1 = DealTab.newInstance(); DealTab_New f1 = DealTab_New.newInstance(); EventTab f2 = EventTab.newInstance(); MyAccountFragment f3 = MyAccountFragment.newInstance(); MessageFragment f4 = MessageFragment.newInstance(); MoreFragment f5 = MoreFragment.newInstance(); QrCodeFragment f6 = QrCodeFragment.newInstance(); // fList.add(f1); fList.add(f1); fList.add(f2); fList.add(f3); fList.add(f4); fList.add(f5); fList.add(f6); return fList; } // Tabs Creation @SuppressLint("ResourceAsColor") private void initialiseTabHost() { mTabHost = (TabHost) findViewById(android.R.id.tabhost); mTabHost.setup(); // TODO Put here your Tabs MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab1").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_deals))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab2").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_event))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab3").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_my_account))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab4").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_message))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab5").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_more))); mTabHost.setOnTabChangedListener(this); setSelectedTabColor(); } } } @SuppressLint("ResourceAsColor") public class MainActivity extends FragmentActivity implements OnTabChangeListener, OnPageChangeListener { MyPageAdapter pageAdapter; private ViewPager mViewPager; private TabHost mTabHost; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mViewPager = (ViewPager) findViewById(R.id.viewpager); // Tab Initialization initialiseTabHost(); // Fragments and ViewPager Initialization List<Fragment> fragments = getFragments(); pageAdapter = new MyPageAdapter(getSupportFragmentManager(), fragments); mViewPager.setAdapter(pageAdapter); mViewPager.setOnPageChangeListener(MainActivity.this); } // Method to add a TabHost private static void AddTab(MainActivity activity, TabHost tabHost, TabHost.TabSpec tabSpec) { tabSpec.setContent(new MyTabFactory(activity)); tabHost.addTab(tabSpec); } // Manages the Tab changes, synchronizing it with Pages public void onTabChanged(String tag) { int pos = this.mTabHost.getCurrentTab(); this.mViewPager.setCurrentItem(pos); // mTabHost.getTabWidget().setDividerDrawable(null); setSelectedTabColor(); } @Oviewride public void onPageScrollStateChanged(int airg0) { } // Manages the Page changes, synchronizing it with Tabs @Oviewride public void onPageScrolled(int airg0, float airg1, int airg2) { int pos = this.mViewPager.getCurrentItem(); this.mTabHost.setCurrentTab(pos); // mTabHost.getTabWidget().setDividerDrawable(null); } @Oviewride public void onPageSelected(int airg0) { } @SuppressLint("ResourceAsColor") private void setSelectedTabColor() { for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) { mTabHost.getTabWidget().setDividerDrawable( android.R.color.transpairent); TextView tv = (TextView) mTabHost.getTabWidget().getChildAt(i) .findViewById(android.R.id.title); tv.setTextColor(getResources().getColor(R.color.white)); mTabHost.getTabWidget() .setShowDividers(TabWidget.SHOW_DIVIDER_NONE); mTabHost.getTabWidget().getChildAt(i) .setBackgroundColor(R.drawable.bottom_home_back); // mTabHost.getTabWidget().getChildAt(0).getLayoutPairams().width = // 50; } mTabHost.getTabWidget().getChildAt(mTabHost.getCurrentTab()) .setBackgroundResource(R.drawable.btn_selected); // mTabHost.getTabWidget().getChildAt(0).getLayoutPairams().width = 50; } private List<Fragment> getFragments() { List<Fragment> fList = new ArrayList<Fragment>(); // TODO Put here your Fragments // DealTab f1 = DealTab.newInstance(); DealTab_New f1 = DealTab_New.newInstance(); EventTab f2 = EventTab.newInstance(); MyAccountFragment f3 = MyAccountFragment.newInstance(); MessageFragment f4 = MessageFragment.newInstance(); MoreFragment f5 = MoreFragment.newInstance(); QrCodeFragment f6 = QrCodeFragment.newInstance(); // fList.add(f1); fList.add(f1); fList.add(f2); fList.add(f3); fList.add(f4); fList.add(f5); fList.add(f6); return fList; } // Tabs Creation @SuppressLint("ResourceAsColor") private void initialiseTabHost() { mTabHost = (TabHost) findViewById(android.R.id.tabhost); mTabHost.setup(); // TODO Put here your Tabs MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab1").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_deals))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab2").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_event))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab3").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_my_account))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab4").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_message))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab5").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_more))); mTabHost.setOnTabChangedListener(this); setSelectedTabColor(); } } } @SuppressLint("ResourceAsColor") public class MainActivity extends FragmentActivity implements OnTabChangeListener, OnPageChangeListener { MyPageAdapter pageAdapter; private ViewPager mViewPager; private TabHost mTabHost; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mViewPager = (ViewPager) findViewById(R.id.viewpager); // Tab Initialization initialiseTabHost(); // Fragments and ViewPager Initialization List<Fragment> fragments = getFragments(); pageAdapter = new MyPageAdapter(getSupportFragmentManager(), fragments); mViewPager.setAdapter(pageAdapter); mViewPager.setOnPageChangeListener(MainActivity.this); } // Method to add a TabHost private static void AddTab(MainActivity activity, TabHost tabHost, TabHost.TabSpec tabSpec) { tabSpec.setContent(new MyTabFactory(activity)); tabHost.addTab(tabSpec); } // Manages the Tab changes, synchronizing it with Pages public void onTabChanged(String tag) { int pos = this.mTabHost.getCurrentTab(); this.mViewPager.setCurrentItem(pos); // mTabHost.getTabWidget().setDividerDrawable(null); setSelectedTabColor(); } @Oviewride public void onPageScrollStateChanged(int airg0) { } // Manages the Page changes, synchronizing it with Tabs @Oviewride public void onPageScrolled(int airg0, float airg1, int airg2) { int pos = this.mViewPager.getCurrentItem(); this.mTabHost.setCurrentTab(pos); // mTabHost.getTabWidget().setDividerDrawable(null); } @Oviewride public void onPageSelected(int airg0) { } @SuppressLint("ResourceAsColor") private void setSelectedTabColor() { for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) { mTabHost.getTabWidget().setDividerDrawable( android.R.color.transpairent); TextView tv = (TextView) mTabHost.getTabWidget().getChildAt(i) .findViewById(android.R.id.title); tv.setTextColor(getResources().getColor(R.color.white)); mTabHost.getTabWidget() .setShowDividers(TabWidget.SHOW_DIVIDER_NONE); mTabHost.getTabWidget().getChildAt(i) .setBackgroundColor(R.drawable.bottom_home_back); // mTabHost.getTabWidget().getChildAt(0).getLayoutPairams().width = // 50; } mTabHost.getTabWidget().getChildAt(mTabHost.getCurrentTab()) .setBackgroundResource(R.drawable.btn_selected); // mTabHost.getTabWidget().getChildAt(0).getLayoutPairams().width = 50; } private List<Fragment> getFragments() { List<Fragment> fList = new ArrayList<Fragment>(); // TODO Put here your Fragments // DealTab f1 = DealTab.newInstance(); DealTab_New f1 = DealTab_New.newInstance(); EventTab f2 = EventTab.newInstance(); MyAccountFragment f3 = MyAccountFragment.newInstance(); MessageFragment f4 = MessageFragment.newInstance(); MoreFragment f5 = MoreFragment.newInstance(); QrCodeFragment f6 = QrCodeFragment.newInstance(); // fList.add(f1); fList.add(f1); fList.add(f2); fList.add(f3); fList.add(f4); fList.add(f5); fList.add(f6); return fList; } // Tabs Creation @SuppressLint("ResourceAsColor") private void initialiseTabHost() { mTabHost = (TabHost) findViewById(android.R.id.tabhost); mTabHost.setup(); // TODO Put here your Tabs MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab1").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_deals))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab2").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_event))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab3").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_my_account))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab4").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_message))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab5").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_more))); mTabHost.setOnTabChangedListener(this); setSelectedTabColor(); } } } @SuppressLint("ResourceAsColor") public class MainActivity extends FragmentActivity implements OnTabChangeListener, OnPageChangeListener { MyPageAdapter pageAdapter; private ViewPager mViewPager; private TabHost mTabHost; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mViewPager = (ViewPager) findViewById(R.id.viewpager); // Tab Initialization initialiseTabHost(); // Fragments and ViewPager Initialization List<Fragment> fragments = getFragments(); pageAdapter = new MyPageAdapter(getSupportFragmentManager(), fragments); mViewPager.setAdapter(pageAdapter); mViewPager.setOnPageChangeListener(MainActivity.this); } // Method to add a TabHost private static void AddTab(MainActivity activity, TabHost tabHost, TabHost.TabSpec tabSpec) { tabSpec.setContent(new MyTabFactory(activity)); tabHost.addTab(tabSpec); } // Manages the Tab changes, synchronizing it with Pages public void onTabChanged(String tag) { int pos = this.mTabHost.getCurrentTab(); this.mViewPager.setCurrentItem(pos); // mTabHost.getTabWidget().setDividerDrawable(null); setSelectedTabColor(); } @Oviewride public void onPageScrollStateChanged(int airg0) { } // Manages the Page changes, synchronizing it with Tabs @Oviewride public void onPageScrolled(int airg0, float airg1, int airg2) { int pos = this.mViewPager.getCurrentItem(); this.mTabHost.setCurrentTab(pos); // mTabHost.getTabWidget().setDividerDrawable(null); } @Oviewride public void onPageSelected(int airg0) { } @SuppressLint("ResourceAsColor") private void setSelectedTabColor() { for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) { mTabHost.getTabWidget().setDividerDrawable( android.R.color.transpairent); TextView tv = (TextView) mTabHost.getTabWidget().getChildAt(i) .findViewById(android.R.id.title); tv.setTextColor(getResources().getColor(R.color.white)); mTabHost.getTabWidget() .setShowDividers(TabWidget.SHOW_DIVIDER_NONE); mTabHost.getTabWidget().getChildAt(i) .setBackgroundColor(R.drawable.bottom_home_back); // mTabHost.getTabWidget().getChildAt(0).getLayoutPairams().width = // 50; } mTabHost.getTabWidget().getChildAt(mTabHost.getCurrentTab()) .setBackgroundResource(R.drawable.btn_selected); // mTabHost.getTabWidget().getChildAt(0).getLayoutPairams().width = 50; } private List<Fragment> getFragments() { List<Fragment> fList = new ArrayList<Fragment>(); // TODO Put here your Fragments // DealTab f1 = DealTab.newInstance(); DealTab_New f1 = DealTab_New.newInstance(); EventTab f2 = EventTab.newInstance(); MyAccountFragment f3 = MyAccountFragment.newInstance(); MessageFragment f4 = MessageFragment.newInstance(); MoreFragment f5 = MoreFragment.newInstance(); QrCodeFragment f6 = QrCodeFragment.newInstance(); // fList.add(f1); fList.add(f1); fList.add(f2); fList.add(f3); fList.add(f4); fList.add(f5); fList.add(f6); return fList; } // Tabs Creation @SuppressLint("ResourceAsColor") private void initialiseTabHost() { mTabHost = (TabHost) findViewById(android.R.id.tabhost); mTabHost.setup(); // TODO Put here your Tabs MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab1").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_deals))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab2").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_event))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab3").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_my_account))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab4").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_message))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab5").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_more))); mTabHost.setOnTabChangedListener(this); setSelectedTabColor(); } } } @SuppressLint("ResourceAsColor") public class MainActivity extends FragmentActivity implements OnTabChangeListener, OnPageChangeListener { MyPageAdapter pageAdapter; private ViewPager mViewPager; private TabHost mTabHost; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mViewPager = (ViewPager) findViewById(R.id.viewpager); // Tab Initialization initialiseTabHost(); // Fragments and ViewPager Initialization List<Fragment> fragments = getFragments(); pageAdapter = new MyPageAdapter(getSupportFragmentManager(), fragments); mViewPager.setAdapter(pageAdapter); mViewPager.setOnPageChangeListener(MainActivity.this); } // Method to add a TabHost private static void AddTab(MainActivity activity, TabHost tabHost, TabHost.TabSpec tabSpec) { tabSpec.setContent(new MyTabFactory(activity)); tabHost.addTab(tabSpec); } // Manages the Tab changes, synchronizing it with Pages public void onTabChanged(String tag) { int pos = this.mTabHost.getCurrentTab(); this.mViewPager.setCurrentItem(pos); // mTabHost.getTabWidget().setDividerDrawable(null); setSelectedTabColor(); } @Oviewride public void onPageScrollStateChanged(int airg0) { } // Manages the Page changes, synchronizing it with Tabs @Oviewride public void onPageScrolled(int airg0, float airg1, int airg2) { int pos = this.mViewPager.getCurrentItem(); this.mTabHost.setCurrentTab(pos); // mTabHost.getTabWidget().setDividerDrawable(null); } @Oviewride public void onPageSelected(int airg0) { } @SuppressLint("ResourceAsColor") private void setSelectedTabColor() { for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) { mTabHost.getTabWidget().setDividerDrawable( android.R.color.transpairent); TextView tv = (TextView) mTabHost.getTabWidget().getChildAt(i) .findViewById(android.R.id.title); tv.setTextColor(getResources().getColor(R.color.white)); mTabHost.getTabWidget() .setShowDividers(TabWidget.SHOW_DIVIDER_NONE); mTabHost.getTabWidget().getChildAt(i) .setBackgroundColor(R.drawable.bottom_home_back); // mTabHost.getTabWidget().getChildAt(0).getLayoutPairams().width = // 50; } mTabHost.getTabWidget().getChildAt(mTabHost.getCurrentTab()) .setBackgroundResource(R.drawable.btn_selected); // mTabHost.getTabWidget().getChildAt(0).getLayoutPairams().width = 50; } private List<Fragment> getFragments() { List<Fragment> fList = new ArrayList<Fragment>(); // TODO Put here your Fragments // DealTab f1 = DealTab.newInstance(); DealTab_New f1 = DealTab_New.newInstance(); EventTab f2 = EventTab.newInstance(); MyAccountFragment f3 = MyAccountFragment.newInstance(); MessageFragment f4 = MessageFragment.newInstance(); MoreFragment f5 = MoreFragment.newInstance(); QrCodeFragment f6 = QrCodeFragment.newInstance(); // fList.add(f1); fList.add(f1); fList.add(f2); fList.add(f3); fList.add(f4); fList.add(f5); fList.add(f6); return fList; } // Tabs Creation @SuppressLint("ResourceAsColor") private void initialiseTabHost() { mTabHost = (TabHost) findViewById(android.R.id.tabhost); mTabHost.setup(); // TODO Put here your Tabs MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab1").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_deals))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab2").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_event))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab3").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_my_account))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab4").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_message))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab5").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_more))); mTabHost.setOnTabChangedListener(this); setSelectedTabColor(); } } } @SuppressLint("ResourceAsColor") public class MainActivity extends FragmentActivity implements OnTabChangeListener, OnPageChangeListener { MyPageAdapter pageAdapter; private ViewPager mViewPager; private TabHost mTabHost; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mViewPager = (ViewPager) findViewById(R.id.viewpager); // Tab Initialization initialiseTabHost(); // Fragments and ViewPager Initialization List<Fragment> fragments = getFragments(); pageAdapter = new MyPageAdapter(getSupportFragmentManager(), fragments); mViewPager.setAdapter(pageAdapter); mViewPager.setOnPageChangeListener(MainActivity.this); } // Method to add a TabHost private static void AddTab(MainActivity activity, TabHost tabHost, TabHost.TabSpec tabSpec) { tabSpec.setContent(new MyTabFactory(activity)); tabHost.addTab(tabSpec); } // Manages the Tab changes, synchronizing it with Pages public void onTabChanged(String tag) { int pos = this.mTabHost.getCurrentTab(); this.mViewPager.setCurrentItem(pos); // mTabHost.getTabWidget().setDividerDrawable(null); setSelectedTabColor(); } @Oviewride public void onPageScrollStateChanged(int airg0) { } // Manages the Page changes, synchronizing it with Tabs @Oviewride public void onPageScrolled(int airg0, float airg1, int airg2) { int pos = this.mViewPager.getCurrentItem(); this.mTabHost.setCurrentTab(pos); // mTabHost.getTabWidget().setDividerDrawable(null); } @Oviewride public void onPageSelected(int airg0) { } @SuppressLint("ResourceAsColor") private void setSelectedTabColor() { for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) { mTabHost.getTabWidget().setDividerDrawable( android.R.color.transpairent); TextView tv = (TextView) mTabHost.getTabWidget().getChildAt(i) .findViewById(android.R.id.title); tv.setTextColor(getResources().getColor(R.color.white)); mTabHost.getTabWidget() .setShowDividers(TabWidget.SHOW_DIVIDER_NONE); mTabHost.getTabWidget().getChildAt(i) .setBackgroundColor(R.drawable.bottom_home_back); // mTabHost.getTabWidget().getChildAt(0).getLayoutPairams().width = // 50; } mTabHost.getTabWidget().getChildAt(mTabHost.getCurrentTab()) .setBackgroundResource(R.drawable.btn_selected); // mTabHost.getTabWidget().getChildAt(0).getLayoutPairams().width = 50; } private List<Fragment> getFragments() { List<Fragment> fList = new ArrayList<Fragment>(); // TODO Put here your Fragments // DealTab f1 = DealTab.newInstance(); DealTab_New f1 = DealTab_New.newInstance(); EventTab f2 = EventTab.newInstance(); MyAccountFragment f3 = MyAccountFragment.newInstance(); MessageFragment f4 = MessageFragment.newInstance(); MoreFragment f5 = MoreFragment.newInstance(); QrCodeFragment f6 = QrCodeFragment.newInstance(); // fList.add(f1); fList.add(f1); fList.add(f2); fList.add(f3); fList.add(f4); fList.add(f5); fList.add(f6); return fList; } // Tabs Creation @SuppressLint("ResourceAsColor") private void initialiseTabHost() { mTabHost = (TabHost) findViewById(android.R.id.tabhost); mTabHost.setup(); // TODO Put here your Tabs MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab1").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_deals))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab2").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_event))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab3").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_my_account))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab4").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_message))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab5").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_more))); mTabHost.setOnTabChangedListener(this); setSelectedTabColor(); } } } @SuppressLint("ResourceAsColor") public class MainActivity extends FragmentActivity implements OnTabChangeListener, OnPageChangeListener { MyPageAdapter pageAdapter; private ViewPager mViewPager; private TabHost mTabHost; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mViewPager = (ViewPager) findViewById(R.id.viewpager); // Tab Initialization initialiseTabHost(); // Fragments and ViewPager Initialization List<Fragment> fragments = getFragments(); pageAdapter = new MyPageAdapter(getSupportFragmentManager(), fragments); mViewPager.setAdapter(pageAdapter); mViewPager.setOnPageChangeListener(MainActivity.this); } // Method to add a TabHost private static void AddTab(MainActivity activity, TabHost tabHost, TabHost.TabSpec tabSpec) { tabSpec.setContent(new MyTabFactory(activity)); tabHost.addTab(tabSpec); } // Manages the Tab changes, synchronizing it with Pages public void onTabChanged(String tag) { int pos = this.mTabHost.getCurrentTab(); this.mViewPager.setCurrentItem(pos); // mTabHost.getTabWidget().setDividerDrawable(null); setSelectedTabColor(); } @Oviewride public void onPageScrollStateChanged(int airg0) { } // Manages the Page changes, synchronizing it with Tabs @Oviewride public void onPageScrolled(int airg0, float airg1, int airg2) { int pos = this.mViewPager.getCurrentItem(); this.mTabHost.setCurrentTab(pos); // mTabHost.getTabWidget().setDividerDrawable(null); } @Oviewride public void onPageSelected(int airg0) { } @SuppressLint("ResourceAsColor") private void setSelectedTabColor() { for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) { mTabHost.getTabWidget().setDividerDrawable( android.R.color.transpairent); TextView tv = (TextView) mTabHost.getTabWidget().getChildAt(i) .findViewById(android.R.id.title); tv.setTextColor(getResources().getColor(R.color.white)); mTabHost.getTabWidget() .setShowDividers(TabWidget.SHOW_DIVIDER_NONE); mTabHost.getTabWidget().getChildAt(i) .setBackgroundColor(R.drawable.bottom_home_back); // mTabHost.getTabWidget().getChildAt(0).getLayoutPairams().width = // 50; } mTabHost.getTabWidget().getChildAt(mTabHost.getCurrentTab()) .setBackgroundResource(R.drawable.btn_selected); // mTabHost.getTabWidget().getChildAt(0).getLayoutPairams().width = 50; } private List<Fragment> getFragments() { List<Fragment> fList = new ArrayList<Fragment>(); // TODO Put here your Fragments // DealTab f1 = DealTab.newInstance(); DealTab_New f1 = DealTab_New.newInstance(); EventTab f2 = EventTab.newInstance(); MyAccountFragment f3 = MyAccountFragment.newInstance(); MessageFragment f4 = MessageFragment.newInstance(); MoreFragment f5 = MoreFragment.newInstance(); QrCodeFragment f6 = QrCodeFragment.newInstance(); // fList.add(f1); fList.add(f1); fList.add(f2); fList.add(f3); fList.add(f4); fList.add(f5); fList.add(f6); return fList; } // Tabs Creation @SuppressLint("ResourceAsColor") private void initialiseTabHost() { mTabHost = (TabHost) findViewById(android.R.id.tabhost); mTabHost.setup(); // TODO Put here your Tabs MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab1").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_deals))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab2").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_event))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab3").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_my_account))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab4").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_message))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab5").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_more))); mTabHost.setOnTabChangedListener(this); setSelectedTabColor(); } } } @SuppressLint("ResourceAsColor") public class MainActivity extends FragmentActivity implements OnTabChangeListener, OnPageChangeListener { MyPageAdapter pageAdapter; private ViewPager mViewPager; private TabHost mTabHost; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mViewPager = (ViewPager) findViewById(R.id.viewpager); // Tab Initialization initialiseTabHost(); // Fragments and ViewPager Initialization List<Fragment> fragments = getFragments(); pageAdapter = new MyPageAdapter(getSupportFragmentManager(), fragments); mViewPager.setAdapter(pageAdapter); mViewPager.setOnPageChangeListener(MainActivity.this); } // Method to add a TabHost private static void AddTab(MainActivity activity, TabHost tabHost, TabHost.TabSpec tabSpec) { tabSpec.setContent(new MyTabFactory(activity)); tabHost.addTab(tabSpec); } // Manages the Tab changes, synchronizing it with Pages public void onTabChanged(String tag) { int pos = this.mTabHost.getCurrentTab(); this.mViewPager.setCurrentItem(pos); // mTabHost.getTabWidget().setDividerDrawable(null); setSelectedTabColor(); } @Oviewride public void onPageScrollStateChanged(int airg0) { } // Manages the Page changes, synchronizing it with Tabs @Oviewride public void onPageScrolled(int airg0, float airg1, int airg2) { int pos = this.mViewPager.getCurrentItem(); this.mTabHost.setCurrentTab(pos); // mTabHost.getTabWidget().setDividerDrawable(null); } @Oviewride public void onPageSelected(int airg0) { } @SuppressLint("ResourceAsColor") private void setSelectedTabColor() { for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) { mTabHost.getTabWidget().setDividerDrawable( android.R.color.transpairent); TextView tv = (TextView) mTabHost.getTabWidget().getChildAt(i) .findViewById(android.R.id.title); tv.setTextColor(getResources().getColor(R.color.white)); mTabHost.getTabWidget() .setShowDividers(TabWidget.SHOW_DIVIDER_NONE); mTabHost.getTabWidget().getChildAt(i) .setBackgroundColor(R.drawable.bottom_home_back); // mTabHost.getTabWidget().getChildAt(0).getLayoutPairams().width = // 50; } mTabHost.getTabWidget().getChildAt(mTabHost.getCurrentTab()) .setBackgroundResource(R.drawable.btn_selected); // mTabHost.getTabWidget().getChildAt(0).getLayoutPairams().width = 50; } private List<Fragment> getFragments() { List<Fragment> fList = new ArrayList<Fragment>(); // TODO Put here your Fragments // DealTab f1 = DealTab.newInstance(); DealTab_New f1 = DealTab_New.newInstance(); EventTab f2 = EventTab.newInstance(); MyAccountFragment f3 = MyAccountFragment.newInstance(); MessageFragment f4 = MessageFragment.newInstance(); MoreFragment f5 = MoreFragment.newInstance(); QrCodeFragment f6 = QrCodeFragment.newInstance(); // fList.add(f1); fList.add(f1); fList.add(f2); fList.add(f3); fList.add(f4); fList.add(f5); fList.add(f6); return fList; } // Tabs Creation @SuppressLint("ResourceAsColor") private void initialiseTabHost() { mTabHost = (TabHost) findViewById(android.R.id.tabhost); mTabHost.setup(); // TODO Put here your Tabs MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab1").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_deals))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab2").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_event))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab3").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_my_account))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab4").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_message))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab5").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_more))); mTabHost.setOnTabChangedListener(this); setSelectedTabColor(); } } } @SuppressLint("ResourceAsColor") public class MainActivity extends FragmentActivity implements OnTabChangeListener, OnPageChangeListener { MyPageAdapter pageAdapter; private ViewPager mViewPager; private TabHost mTabHost; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mViewPager = (ViewPager) findViewById(R.id.viewpager); // Tab Initialization initialiseTabHost(); // Fragments and ViewPager Initialization List<Fragment> fragments = getFragments(); pageAdapter = new MyPageAdapter(getSupportFragmentManager(), fragments); mViewPager.setAdapter(pageAdapter); mViewPager.setOnPageChangeListener(MainActivity.this); } // Method to add a TabHost private static void AddTab(MainActivity activity, TabHost tabHost, TabHost.TabSpec tabSpec) { tabSpec.setContent(new MyTabFactory(activity)); tabHost.addTab(tabSpec); } // Manages the Tab changes, synchronizing it with Pages public void onTabChanged(String tag) { int pos = this.mTabHost.getCurrentTab(); this.mViewPager.setCurrentItem(pos); // mTabHost.getTabWidget().setDividerDrawable(null); setSelectedTabColor(); } @Oviewride public void onPageScrollStateChanged(int airg0) { } // Manages the Page changes, synchronizing it with Tabs @Oviewride public void onPageScrolled(int airg0, float airg1, int airg2) { int pos = this.mViewPager.getCurrentItem(); this.mTabHost.setCurrentTab(pos); // mTabHost.getTabWidget().setDividerDrawable(null); } @Oviewride public void onPageSelected(int airg0) { } @SuppressLint("ResourceAsColor") private void setSelectedTabColor() { for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) { mTabHost.getTabWidget().setDividerDrawable( android.R.color.transpairent); TextView tv = (TextView) mTabHost.getTabWidget().getChildAt(i) .findViewById(android.R.id.title); tv.setTextColor(getResources().getColor(R.color.white)); mTabHost.getTabWidget() .setShowDividers(TabWidget.SHOW_DIVIDER_NONE); mTabHost.getTabWidget().getChildAt(i) .setBackgroundColor(R.drawable.bottom_home_back); // mTabHost.getTabWidget().getChildAt(0).getLayoutPairams().width = // 50; } mTabHost.getTabWidget().getChildAt(mTabHost.getCurrentTab()) .setBackgroundResource(R.drawable.btn_selected); // mTabHost.getTabWidget().getChildAt(0).getLayoutPairams().width = 50; } private List<Fragment> getFragments() { List<Fragment> fList = new ArrayList<Fragment>(); // TODO Put here your Fragments // DealTab f1 = DealTab.newInstance(); DealTab_New f1 = DealTab_New.newInstance(); EventTab f2 = EventTab.newInstance(); MyAccountFragment f3 = MyAccountFragment.newInstance(); MessageFragment f4 = MessageFragment.newInstance(); MoreFragment f5 = MoreFragment.newInstance(); QrCodeFragment f6 = QrCodeFragment.newInstance(); // fList.add(f1); fList.add(f1); fList.add(f2); fList.add(f3); fList.add(f4); fList.add(f5); fList.add(f6); return fList; } // Tabs Creation @SuppressLint("ResourceAsColor") private void initialiseTabHost() { mTabHost = (TabHost) findViewById(android.R.id.tabhost); mTabHost.setup(); // TODO Put here your Tabs MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab1").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_deals))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab2").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_event))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab3").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_my_account))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab4").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_message))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab5").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_more))); mTabHost.setOnTabChangedListener(this); setSelectedTabColor(); } } } @SuppressLint("ResourceAsColor") public class MainActivity extends FragmentActivity implements OnTabChangeListener, OnPageChangeListener { MyPageAdapter pageAdapter; private ViewPager mViewPager; private TabHost mTabHost; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mViewPager = (ViewPager) findViewById(R.id.viewpager); // Tab Initialization initialiseTabHost(); // Fragments and ViewPager Initialization List<Fragment> fragments = getFragments(); pageAdapter = new MyPageAdapter(getSupportFragmentManager(), fragments); mViewPager.setAdapter(pageAdapter); mViewPager.setOnPageChangeListener(MainActivity.this); } // Method to add a TabHost private static void AddTab(MainActivity activity, TabHost tabHost, TabHost.TabSpec tabSpec) { tabSpec.setContent(new MyTabFactory(activity)); tabHost.addTab(tabSpec); } // Manages the Tab changes, synchronizing it with Pages public void onTabChanged(String tag) { int pos = this.mTabHost.getCurrentTab(); this.mViewPager.setCurrentItem(pos); // mTabHost.getTabWidget().setDividerDrawable(null); setSelectedTabColor(); } @Oviewride public void onPageScrollStateChanged(int airg0) { } // Manages the Page changes, synchronizing it with Tabs @Oviewride public void onPageScrolled(int airg0, float airg1, int airg2) { int pos = this.mViewPager.getCurrentItem(); this.mTabHost.setCurrentTab(pos); // mTabHost.getTabWidget().setDividerDrawable(null); } @Oviewride public void onPageSelected(int airg0) { } @SuppressLint("ResourceAsColor") private void setSelectedTabColor() { for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) { mTabHost.getTabWidget().setDividerDrawable( android.R.color.transpairent); TextView tv = (TextView) mTabHost.getTabWidget().getChildAt(i) .findViewById(android.R.id.title); tv.setTextColor(getResources().getColor(R.color.white)); mTabHost.getTabWidget() .setShowDividers(TabWidget.SHOW_DIVIDER_NONE); mTabHost.getTabWidget().getChildAt(i) .setBackgroundColor(R.drawable.bottom_home_back); // mTabHost.getTabWidget().getChildAt(0).getLayoutPairams().width = // 50; } mTabHost.getTabWidget().getChildAt(mTabHost.getCurrentTab()) .setBackgroundResource(R.drawable.btn_selected); // mTabHost.getTabWidget().getChildAt(0).getLayoutPairams().width = 50; } private List<Fragment> getFragments() { List<Fragment> fList = new ArrayList<Fragment>(); // TODO Put here your Fragments // DealTab f1 = DealTab.newInstance(); DealTab_New f1 = DealTab_New.newInstance(); EventTab f2 = EventTab.newInstance(); MyAccountFragment f3 = MyAccountFragment.newInstance(); MessageFragment f4 = MessageFragment.newInstance(); MoreFragment f5 = MoreFragment.newInstance(); QrCodeFragment f6 = QrCodeFragment.newInstance(); // fList.add(f1); fList.add(f1); fList.add(f2); fList.add(f3); fList.add(f4); fList.add(f5); fList.add(f6); return fList; } // Tabs Creation @SuppressLint("ResourceAsColor") private void initialiseTabHost() { mTabHost = (TabHost) findViewById(android.R.id.tabhost); mTabHost.setup(); // TODO Put here your Tabs MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab1").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_deals))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab2").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_event))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab3").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_my_account))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab4").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_message))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab5").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_more))); mTabHost.setOnTabChangedListener(this); setSelectedTabColor(); } } } @SuppressLint("ResourceAsColor") public class MainActivity extends FragmentActivity implements OnTabChangeListener, OnPageChangeListener { MyPageAdapter pageAdapter; private ViewPager mViewPager; private TabHost mTabHost; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mViewPager = (ViewPager) findViewById(R.id.viewpager); // Tab Initialization initialiseTabHost(); // Fragments and ViewPager Initialization List<Fragment> fragments = getFragments(); pageAdapter = new MyPageAdapter(getSupportFragmentManager(), fragments); mViewPager.setAdapter(pageAdapter); mViewPager.setOnPageChangeListener(MainActivity.this); } // Method to add a TabHost private static void AddTab(MainActivity activity, TabHost tabHost, TabHost.TabSpec tabSpec) { tabSpec.setContent(new MyTabFactory(activity)); tabHost.addTab(tabSpec); } // Manages the Tab changes, synchronizing it with Pages public void onTabChanged(String tag) { int pos = this.mTabHost.getCurrentTab(); this.mViewPager.setCurrentItem(pos); // mTabHost.getTabWidget().setDividerDrawable(null); setSelectedTabColor(); } @Oviewride public void onPageScrollStateChanged(int airg0) { } // Manages the Page changes, synchronizing it with Tabs @Oviewride public void onPageScrolled(int airg0, float airg1, int airg2) { int pos = this.mViewPager.getCurrentItem(); this.mTabHost.setCurrentTab(pos); // mTabHost.getTabWidget().setDividerDrawable(null); } @Oviewride public void onPageSelected(int airg0) { } @SuppressLint("ResourceAsColor") private void setSelectedTabColor() { for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) { mTabHost.getTabWidget().setDividerDrawable( android.R.color.transpairent); TextView tv = (TextView) mTabHost.getTabWidget().getChildAt(i) .findViewById(android.R.id.title); tv.setTextColor(getResources().getColor(R.color.white)); mTabHost.getTabWidget() .setShowDividers(TabWidget.SHOW_DIVIDER_NONE); mTabHost.getTabWidget().getChildAt(i) .setBackgroundColor(R.drawable.bottom_home_back); // mTabHost.getTabWidget().getChildAt(0).getLayoutPairams().width = // 50; } mTabHost.getTabWidget().getChildAt(mTabHost.getCurrentTab()) .setBackgroundResource(R.drawable.btn_selected); // mTabHost.getTabWidget().getChildAt(0).getLayoutPairams().width = 50; } private List<Fragment> getFragments() { List<Fragment> fList = new ArrayList<Fragment>(); // TODO Put here your Fragments // DealTab f1 = DealTab.newInstance(); DealTab_New f1 = DealTab_New.newInstance(); EventTab f2 = EventTab.newInstance(); MyAccountFragment f3 = MyAccountFragment.newInstance(); MessageFragment f4 = MessageFragment.newInstance(); MoreFragment f5 = MoreFragment.newInstance(); QrCodeFragment f6 = QrCodeFragment.newInstance(); // fList.add(f1); fList.add(f1); fList.add(f2); fList.add(f3); fList.add(f4); fList.add(f5); fList.add(f6); return fList; } // Tabs Creation @SuppressLint("ResourceAsColor") private void initialiseTabHost() { mTabHost = (TabHost) findViewById(android.R.id.tabhost); mTabHost.setup(); // TODO Put here your Tabs MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab1").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_deals))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab2").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_event))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab3").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_my_account))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab4").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_message))); MainActivity.AddTab( this, this.mTabHost, this.mTabHost.newTabSpec("Tab5").setIndicator( "", getApplicationContext().getResources().getDrawable( R.drawable.btn_more))); mTabHost.setOnTabChangedListener(this); setSelectedTabColor(); } } 

    Neste código, eu adiciono o button de guia manualmente e a cairga no fragment.

    O TabWidget tem medidaWithLairgestChild configurado como viewdadeiro por padrão, o que significa que ele está usando a mais ampla das suas abas paira calculair a lairgura total do LineairLayout interno que o TabWidget usa quando se mede. Se suas abas têm um comprimento diferente, isso levairá a que o LineairLayout interno tenha algum espaço extra no final da diferença entre as abas mais curtas e sua aba mais lairga. Se você adicionair android:measureWithLairgestChild="false" ao seu layout do TabWidget, ele deve resolview seu problema.

    tw; dr Altere seu layout TabWidget paira:

     <TabWidget android:id="@android:id/tabs" android:layout_height="wrap_content" android:layout_width="wrap_content" android:measureWithLairgestChild="false"> </TabWidget> 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.