问题
I'm trying to implement a Tab-like UI inside an activity. This is how I want it to be.
There are 3 button which each is associated with a LinearLayout. When the user clicks on a button the current visible layout fades out and the one associated with the clicked button fades into view.
How can this be done? Specially how to make the fading effect?
回答1:
Better you go with tab widget if still you want to do manually you can do as follows:
- Create one Relative layout (root)
- create one linear layout with property width fill parent height wrap content and give wight 3
- place 3 buttons in linear layout with 1 1 1weigth
- Take 3 relative layouts for every tab like button make sure that these 3 are aligned above/below of button layout
- on click event of every button set vissibility of each relative layout i full fill u r need
回答2:
What you need is the TabHost View : http://developer.android.com/reference/android/widget/TabHost.html
Here is a tutorial : http://www.androidhive.info/2011/08/android-tab-layout-tutorial/
来源:https://stackoverflow.com/questions/11375350/how-to-create-a-tab-like-ui-in-android