title: HorizontalScrollView in TabHost adding extra space on the end
body: <p>In order to easily switch between fragments, I'm embedding a HorizontalScrollView into my Tab layout like so:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;TabHost xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@android:id/tabhost"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
      &lt;LinearLayout
          android:orientation="vertical"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
  
          &lt;HorizontalScrollView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:fillViewport="true"
              android:scrollbars="none" &gt;
  
              &lt;TabWidget android:id="@android:id/tabs" 
                  android:layout_height="wrap_content" 
                  android:layout_width="wrap_content"&gt;
              &lt;/TabWidget&gt;
          &lt;/HorizontalScrollView&gt;
          &lt;FrameLayout
              android:id="@android:id/tabcontent"
              android:layout_width="match_parent"
              android:layout_height="wrap_content" /&gt;
      &lt;/LinearLayout&gt;
  &lt;/TabHost&gt;
  </code></pre>
  
  <p>But after adding Fragments in my code (shown below) there suddenly shows up some extra whitespace at the end of the HorizontalScrollView:</p>
  
  <p><strong>Before scrolling</strong></p>
  
  <p><img src="https://i.stack.imgur.com/XbDaX.png" alt="Before scrolling"></p>
  
  <p><strong>After scrolling</strong></p>
  
  <p><img src="https://i.stack.imgur.com/Qnc8T.png" alt="After scrolling"></p>
  
  <p>The code is quite complex but I'll try to show the important parts.</p>
  
  <pre><code>{
      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 &lt; list.size(); i++) {
          mTabHost.addTab(newTab(String.valueOf(i), list.get(i).getTitle(), tabsFL.getId()));
      }
  
      mTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
          @Override
          public void onTabChanged(String tabId) {
          updateTab(tabId, Integer.parseInt(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.parseInt(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&lt;CustomObject&gt; frags) {
      mCurrentTab = id;
  
      FragmentManager fm = activity.getSupportFragmentManager();
      fm.beginTransaction()
          .replace(TABS_FRAME_ID, DetailsFragment.newInstance(frags.get(id)), tabId)
          .commitAllowingStateLoss();
  }
  </code></pre>
  
  <p>Also unrelated, but I also have a problem where the first tab doesn't load manually (clicking tabs loads the Fragments perfectly, just the very first one doesn't load for some reason).</p>