42

What is a good Android analog of iOS's UISegmentedControl?

nmr
  • 16,625
  • 10
  • 53
  • 67
Venugopal
  • 1,288
  • 3
  • 19
  • 31

2 Answers2

33

I just wrote a similar implementation here: https://github.com/makeramen/android-segmentedradiobutton

It overrides RadioGroup instead of RadioButton and doesn't override the onDraw method so XML styling still works.

vinc3m1
  • 4,075
  • 1
  • 26
  • 23
  • 4
    For any one who don't want to have so many resource image files, you may define your RadioButton background like this [segmented_button_background_first.xml](http://code.google.com/p/android-batsg/source/browse/android-batsg-demo/res/drawable/segmented_button_background_first.xml) file (there is more sample [here](http://code.google.com/p/android-batsg/source/browse/android-batsg-demo/res/drawable)). I also rewrite makeramen's code for more flexible use like [this](http://code.google.com/p/android-batsg/wiki/SegmentedControl) – umbalaconmeogia Feb 12 '12 at 10:26
  • @umbalaconmeogia that looks awesome, feel free to submit as a pull request if you want! – vinc3m1 Feb 13 '12 at 00:29
12

Benjamin Ferrari has a nice implementation here: http://blog.bookworm.at/2010/10/segmented-controls-in-android.html . Essentially he's just overridden the RadioButton.

cagreen
  • 1,627
  • 1
  • 14
  • 29
  • 1
    He added a github project that contains a library that you can include in your project that has ICS styled controls that are really slick. Here's the link [https://github.com/bookwormat/segcontrol](https://github.com/bookwormat/segcontrol) – AngeloS Aug 23 '12 at 19:11