开发者

Scrolling Tabhost at the bottom

I used the tabhost tutorial to get started with the Tabhost control.

After some play around I wanted to make the tabhost scrollable, which I figured out.

Now I want the tabhost at the bottom of the display which is just not working for me.

Switched to Relative Layout which was suggested here: iPhone-like Tabbar

My code:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:scrollbars="horizontal" android:isScrollContainer="true">
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost" android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:layout_alignParentBottom="true">
    <RelativeLayout android:layout_height="fill_parent"
        android:layout_width="fill_parent">
        <HorizontalScrollView android:layout_width="fill_parent"
            android:layout_height="fill_parent" android:scrollbars="none"
            android:layout_alignParentBottom="true">
            <TabWidget android:id="@android:id/tabs"
                android:layout_alignParentBottom="true" android:layout_width="fill_parent"
                android:layout_height="wrap_content" />
        </HorizontalScrollView>
        <FrameLayout android:id="@android:id/tabcontent"
            android:layout_width="fill_parent" android:layout_height="fill_parent"
            android:padding="2dp" />
    </RelativeLayout>
</TabHost>

I need a hint why it's not working / how thi开发者_如何学编程s would work. I tried with relative layout and layout_alignParentBottom="true" now it's there a few times (in the HorizontalScrollView and the TabWidget)


Thanks to Arve leading me to "custom controls" I found a promising project:

https://github.com/honcheng/ScrollableTabHost-for-Android

I hope some others looking for this kind of tabhost can use it :)


A possible library to help you do this: http://code.google.com/p/androidtabs/

From their project description:

Due to limitation of Android Tab component I created a custom TabWidget that I am using in couple different projects already. The widget allows us to add custom background and use custom icons, tabs can be Top/Bottom aligned.

EDIT: I have not tested this myself, but it looks promising.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜