I created a TabLayout referring to this tutorial: https://guides.codepath.com/android/google-play-style-tabs-using-tablayout
My xml looks like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#E0E0E0"
android:orientation="vertical"
tools:context="com.blabla.activities.MainActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:theme="@style/AppTheme"
app:logo="@drawable/test_24px"
app:popupTheme="@style/Theme.AppCompat.Light.DarkActionBar"
app:title="@string/app_name"
app:titleMarginStart="24dp"
app:titleTextColor="@android:color/white">
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
style="@style/MyCustomTabLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbar"
android:background="?attr/colorPrimary"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
</android.support.v7.widget.Toolbar>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_below="@id/tab_layout" />
</LinearLayout><!--android.support.design.widget.AppBarLayout-->
So my TabLayout is inside the Toolbar. But I just want to have this in the landscape mode to save space. But in the normal portrait mode I want the TabLayout underneath the Toolbar.
What is the best way to achieve this?