How to create horizantal scrollable tabbar bar in android?

I would like to create tabbar as shown in the image how can i do it in androidwith arrow when the opitions are more then four how it is possible in android?

As shown in the second screen when the user presses the right side arrow button other opitions are appear how can i write code for this please help me regard this...

Thanks in advance.

Upvotes: 3

Views: 4296

Answers (1)

Jin35
Jin35

Reputation: 8612

If you don't want something more complicated than just scrolling tabs with arrows you can wrap your TabWidget by HorizontalScrollView and LinearLayout.

<?xml version="1.0" encoding="utf-8"?>
<TabHost
    xmlns:android="http://schemas.android.com/apk/res/android"
    params="...">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
            <LinearLayout>
                 <ImageView
                     params="..."/>
                 <HorizontalScrollView
                     params="...">
                      <TabWidget
                          params="..." />
                 </HorizontalScrollView>
                 <ImageView
                     params="..."/>
            </LinearLayout>
        <FrameLayout
            android:id="@android:id/tabcontent"
            params="..." />
    </LinearLayout>
</TabHost>

And in code you should set OnScrollListener for HorizontalScrollView to disappear ImageView of arrows

Upvotes: 3

Related Questions