gpt4 book ai didi

android - 具有协调器布局的 ViewPager

转载 作者:太空宇宙 更新时间:2023-11-03 10:42:04 25 4
gpt4 key购买 nike

我有一个如下所示的 Activity 布局:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">

<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
app:layout_scrollFlags="scroll|enterAlways"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary" />

<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>

<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="match_parent" />

viewpager 有两个 fragment ,一个带有 RecyclerView,一个带有 LinearLayout。

带有 RecyclerView 的 fragment 按预期工作,当滚动 RecyclerView 时,操作栏会滚出屏幕。

不过,另一个带有 LinearLayout 的 fragment 没有像我希望的那样显示。 LinearLayout 绘制在 TabLayout 下方并延伸到屏幕外。我希望调整它的大小以填充 TabLayout 下面的可用空间而不扩展到屏幕外。线性布局看起来像这样:

    <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">

<LinearLayout
android:id="@+id/station_detail_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<include
layout="@layout/station_detail_title"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3" />

<include
layout="@layout/station_detail_body"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2" />


</LinearLayout>

<TextView
android:id="@+id/text_view_station_detail_empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal|center_vertical"
android:text="@string/text_view_station_detail_empty"
android:visibility="gone" />
</LinearLayout>

感谢您的帮助,非常感谢!

最佳答案

我认为您需要将嵌套 ScrollView 添加到您的线性布局中。

关于android - 具有协调器布局的 ViewPager,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31869406/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com