问题描述:

I'm having a bit of a problem with the Android tab layout. I've been trying to make a screen that holds 4 tabs, and a fragment beneath them, when a user presses each tab the fragment dynamically switches to another activity and the tabs stay static, my problem is that I tried to implement it with tab layout and it's deprecated in since Android 4.0, so I tried it with the action bar tabs but then I have the action bar that I don't want nor need.

I have two questions:

  1. Is it possible to use action bar but to hide the action bar and show only the tabs?
  2. Is there a way to use tab layout on Android 4.0 and higher versions?

网友答案:

1.Yes there is possibility.....you should try http://actionbarsherlock.com/

2.ActionBarSherlock works from sdk 7 to sdk 16

网友答案:
  1. I am not really sure about whether you can achieve it or not but if you want to play around with the ActionBar, this would be one of the best places to start.

  2. Just because it is deprecated, doesn't mean that you can't use tabs in Android 4+. ;)

    You surely can use Tabs and TabLayout in Android 4+ and everything works perfectly(though you apparently should not as ActionBar is a must better option).

    I have tried it myself because even I prefer the TabLayout more than the ActionBar, and thankfully haven't run into any issues until now!

    The only thing you will notice is that Eclipse will draw a yellow line over the deprecated code (which you can obviously ignore or just choose to hide all deprecated warnings).

相关阅读:
Top