0

I don't like the way the tabs look with the native tab control in Android so I'd like to create my own control. I can create and draw my own tabs in a horizontal LinearLayout at the top of the screen using a vertical LL, but how do I setup the various hidden tab contents in the XML and how do I show/hide them?

Any potential issues?

  • FYI, you can set a custom View for the contents of a Tab on Android 1.6+ (http://developer.android.com/reference/android/widget/TabHost.TabSpec.html#setIndicator(android.view.View)) – Yoni Samlan Dec 29 '10 at 17:48
  • I want to change the way the tab itself looks, not the contents of the tab. I simply created three custom views and implemented onDraw and onTouch. I just don't know how to setup and switch between the various 'tab' pages. –  Dec 29 '10 at 18:25
  • I found a way to draw my tabs in XML. Based on the answer to this question: http://stackoverflow.com/questions/1521640/standard-android-button-with-a-different-color –  Dec 29 '10 at 22:15

2 Answers2

0

I would recommend using the source code for the existing tab control as a starting place to build your new widget. If you're truly just changing the look and feel, this is a much less error-prone option.

codelark
  • 12,254
  • 1
  • 45
  • 49
  • I'm hoping a button click to switch a view isn't too complicated. I just need to know how to create them and change them in the onClick handler. I already have the tabs working fine. –  Dec 29 '10 at 17:29
0

I used FrameLayout and its just a matter of setting the visibility. I'm not sure why this took so long to figure out, I must have been searching wrong online.

        tab1.setVisibility(View.INVISIBLE);
        tab2.setVisibility(View.VISIBLE);