After I moved my app to 5.0, I had to move from the basic tabs to the slidingTabLayout that a google developer provides .
The problem is, I can't figure out how to center both buttons in a way that they get both centered like the old one. Btw, I'm not talking about the style, just the positioning of the buttons, sharing the same amount o widht space! To make things clear I'll post some images:
What I have now:
What I expect to have:
My layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"></include>
<com.maddogs.mymoney.views.SlidingTabLayout
android:id="@+id/requestSlideTab"
android:layout_width="match_parent"
android:layout_height="wrap_content"></com.maddogs.mymoney.views.SlidingTabLayout>
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.maddogs.mymoney.RequestActivity" />
</LinearLayout>
Thank you very much !
use
setDistributeEvenly()
, it will do what you want. like this:EDIT: SlidingTabLayout copied from Google IO
Why wouldn't you use the PagerSlidingTabStrip lib?
With this lib, you only have to call
setShouldExpand(true)
. If the total width of the tabs doesn't exceed the screen's width, the tabs container will be expanded to match the screen width.I really think you should use this lib, it's pretty good and very easy to use.
in class SlidingTabLayout method populateTabStrip() add