0

enter image description here

In this picture I am trying to get the image to take up the whole top and bottom area that is black. I looked into these links here but I am just not having any luck so far:

http://joshclemm.com/blog/?p=136

Android remove space between tabs in tabwidget

How to change the Tabs Images in the TabHost

The code:

MainActivity:

// Add the Tabs/////////////////////////////////////////////
    th = (TabHost) findViewById(R.id.tabhost);
    th.setup();

    specs = th.newTabSpec("tag1");
    specs.setContent(R.id.tab1);
    specs.setIndicator("", getResources().getDrawable(R.drawable.b_news));
    th.addTab(specs);

    specs = th.newTabSpec("tag2");
    specs.setContent(R.id.tab2);
    specs.setIndicator("Library");
    th.addTab(specs);

    specs = th.newTabSpec("tag3");
    specs.setContent(R.id.tab3);
    specs.setIndicator("Community");
    th.addTab(specs);

main_activity.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TabHost
    android:id="@+id/tabhost"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#ffffff" >

            <LinearLayout
                android:id="@+id/tab1"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <WebView
                    android:id="@+id/webView1"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/tab2"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="#000000" >

                <ListView
                    android:id="@+id/libraryListView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    tools:ignore="InefficientWeight" >
                </ListView>
            </LinearLayout>

            <LinearLayout
                android:id="@+id/tab3"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="#000000" >

                <ListView
                    android:id="@+id/communityListView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    tools:ignore="InefficientWeight" >
                </ListView>
            </LinearLayout>
        </FrameLayout>

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="-4dp"
            android:layout_weight="0" >
        </TabWidget>
    </LinearLayout>
</TabHost>

</RelativeLayout>
Community
  • 1
  • 1
John Ubonty
  • 661
  • 1
  • 5
  • 13

2 Answers2

1
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    params.weight = 1.0f;
    params.gravity = Gravity.CENTER;

    mTabHost.getTabWidget().getChildAt(0).setLayoutParams(params);
    mTabHost.getTabWidget().getChildAt(1).setLayoutParams(params);
    mTabHost.getTabWidget().getChildAt(2).setLayoutParams(params);
    mTabHost.getTabWidget().getChildAt(3).setLayoutParams(params);
-1

The answer was in the links I provided. I just needed to look a little bit more into it.

John Ubonty
  • 661
  • 1
  • 5
  • 13