How to create a Tab-like UI in Android?

泄露秘密 提交于 2019-12-11 19:32:45

问题


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:

  1. Create one Relative layout (root)
  2. create one linear layout with property width fill parent height wrap content and give wight 3
  3. place 3 buttons in linear layout with 1 1 1weigth
  4. Take 3 relative layouts for every tab like button make sure that these 3 are aligned above/below of button layout
  5. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!