Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make a scrollable TabBar...?

I'm working on an app that needs many TabBar Items (6 or 7). I don't think users like to click the "More" button on TabBars, so I'm wondering how to make my own TabBar that slides from left to right, so one can easily access all the buttons on the tabbar without pressing "More."

Thanks!

like image 592
Jameel Avatar asked Jan 21 '12 22:01

Jameel


People also ask

How do I create a dynamic tab in flutter?

To make dynamic tab you can use a List and keep appending the list on every button click. Trick: Clear List and redraw an empty widget and again draw the widgets as per your list.

How do you use TabController in flutter?

The selected tab's index can be changed with animateTo. A stateful widget that builds a TabBar or a TabBarView can create a TabController and share it directly. When the TabBar and TabBarView don't have a convenient stateful ancestor, a TabController can be shared by providing a DefaultTabController inherited widget.


2 Answers

I agree with the other answer that it's a bad idea from a design standpoint.

Nevertheless, the technical answer is that you can simply embed a UITabBar in a UIScrollView. If you set the tab bar's width and the scroll view's contentSize appropriately, the tab bar will be scrollable. You will probably want to turn off bouncing and scroll indicators.

I didn't try it with a UITarBarController.

like image 130
rob mayoff Avatar answered Oct 21 '22 19:10

rob mayoff


Opinions on whether this is a good idea or not aside

A simple carousel should be fairly simple to implement from scratch using a UIScrollView with UIButton subviews. which will provide all the scroll mechanics for you

As a sample idea.

  • A UISCrollView which spans the width of the device.
  • N buttons across the scroll content pane
  • Restrict scroller to horizontal scrolling.
  • Provide selected and unselected images for the buttons
  • Create glue code to ensure only one button is selected at a time (like Radio buttons)

But I do agree with the other posters that its a bad UI idea. Id be thinking UIToolbar for this.

like image 27
Warren Burton Avatar answered Oct 21 '22 18:10

Warren Burton