I am using a TabLayout
and ViewPager
to display ActionBar tabs
following the guide Google Play Style Tabs using TabLayout, however my tabs are squished to the left side of the ActionBar, shown below:
And I would like them to take up the whole bar with equal widths. I've made only a few minor changes to the guide:
In activity_main.xml a style was created to show the ActionBar:
<android.support.design.widget.TabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/AppTheme"
app:tabMode="scrollable" />
Here is the styles.xml code:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowActionBar">true</item>
<item name="tabIndicatorColor">#ffff0030</item>
</style>
Also, my MainActivity
now extends AppCompatActivity
instead of a FragmentActivity
.
app:tabGravity="fill"