【发布时间】:2017-12-01 10:01:21
【问题描述】:
如何在 youtube 应用程序中显示的横向模式下组合工具栏和 Tablayout?我似乎找不到明确的答案。
我目前的布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark"/>
<android.support.design.widget.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
app:tabMode="fixed"
app:tabGravity="fill"/>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:background="@color/transparent"/>
</LinearLayout>
【问题讨论】:
-
这是来自标签的屏幕截图,因为我在我的设备中看不到这种行为
-
提示:工具栏是
ViewGroup。您可以将TabLayout放入其中。在横向模式下的平板电脑布局中。 -
这确实是 Lollypop 设备上最新版本应用程序的屏幕截图。它处于横向模式。
-
@R.Zagórski 这可以在 XML 中完成吗?
-
当然,你试过了吗?看how to add content 到
Toolbar。
标签: android android-view android-tabs android-tablayout