Skip to content Skip to sidebar Skip to footer

Android Tab Widget Won't Fill The Width Of The Screen

I'm completely new to Android dev and XML. What I'm trying to do is create 4 tabs at the bottom of the screen, and for the tabs to fill the width of the screen. I have been able to

Solution 1:

Your problem is that TabHost is derived from FrameLayout, which, as the description states, is only for holding one element, and you're stuffing it with two: a TabWidget and a FrameLayout.

Try this: (note how I also removed FrameLayout - trying to fill in tabs like that is a bad idea)

<?xml version="1.0" encoding="utf-8"?><!-- Dublin Bus App --><TabHostxmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:layout_width="fill_parent"android:layout_height="fill_parent"android:id="@+id/tab_host"><LinearLayoutandroid:orientation="vertical"android:layout_width="fill_parent"android:layout_height="fill_parent"><TabWidgetandroid:id="@android:id/tabs"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_gravity="bottom"/><FrameLayoutandroid:id="@android:id/tabcontent"android:layout_width="fill_parent"android:layout_height="fill_parent"android:padding="5dp" /></LinearLayout></TabHost>

Then follow the HelloTabWidget tutorial to fill the tabs with content.

Solution 2:

Try android:width="match_parent"

Post a Comment for "Android Tab Widget Won't Fill The Width Of The Screen"