rootLogin
rootLogin

Reputation: 11

Layout with ListView and TabHost on Android

I want make a layout like this:

image1

The thing with the action bar is fine, I made it work. But the left list with the images is displayed over the whole display when I create a ListView, so you can't see the TabHost on the right side. So how can I make a ListView on the left and a TabHost right, so that the list is 20% of the display and the tab 80%?

So that you can select an image in the list and do something with it in the tabs. It's for tablets and I work with the Honeycomb 3.0 API. My Layout is like this:

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">

<LinearLayout
    android:id="@+id/linearLayout2"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ListView
        android:id="@+id/id_list_view"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent" />

</LinearLayout>

<LinearLayout
    android:id="@+id/linearLayout2"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:orientation="vertical" >


<TabHost
    android:id="@+id/tabhost"
    android:layout_width="wrap_content"
    android:layout_height="match_parent" >

    <LinearLayout
        android:id="@+id/linearLayout3"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >
        </TabWidget>

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >
        </FrameLayout>
    </LinearLayout>
</TabHost>
</LinearLayout>

Upvotes: 1

Views: 516

Answers (2)

Cata
Cata

Reputation: 11211

I recommend you to make this screen using Fragments, it's the best and the correct way to achieve what you want

Upvotes: 1

Yugandhar Babu
Yugandhar Babu

Reputation: 10349

Keep layout weight property for both vertical Linear Layouts as 0.2 and 0.8 respectively and keep layout width equal to 0 pixels for both vertical Linear Layouts.

Upvotes: 0

Related Questions