gpt4 book ai didi

android - 工具栏不会隐藏在列表滚动中

转载 作者:行者123 更新时间:2023-11-29 20:13:37 25 4
gpt4 key购买 nike

所以,我有这个主要的 Activity 布局,使用 CoordinatorLayout 来显示工具栏和它下面的选项卡:

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

<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"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="0dp"
local:layout_scrollFlags="scroll|enterAlways"
local:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:elevation="4dp"
local:tabMode="fixed"
local:tabGravity="fill"/>

</android.support.design.widget.AppBarLayout>

<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:foreground="@drawable/header_shadow"
local:layout_behavior="@string/appbar_scrolling_view_behavior" />

</android.support.design.widget.CoordinatorLayout>

然后我有 2 个 fragment 布局,每个布局对应我将拥有的 2 个选项卡中的每一个。一个 fragment 在其内容上显示一个 ListView:

<FrameLayout
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:foreground="@drawable/header_shadow"
tools:context=".StationsFragment">

<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh_layout"
android:layout_height="wrap_content"
android:layout_width="match_parent">

<ListView
android:id="@+id/stations_listview"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</android.support.v4.widget.SwipeRefreshLayout>

</FrameLayout>

当我滚动上面的 ListView 时,我希望我的工具栏隐藏,我的代码应该没问题,至少从我在这个 answer 中读到的内容来看是这样。 ,但它不起作用。目前我试图从 fragment Activity 中删除 FrameLayout 但这并没有解决问题。我考虑过对 ListView 中的滚动事件进行硬编码,但如果可能的话,我真的希望它能在没有代码的情况下工作。

提前致谢。

最佳答案

这是因为您将 CoordinatorLayoutListView 一起使用。您可以将实现更改为 RecyclerView 以实现正确的滚动。

检查我的答案 here .这可能对您有所帮助。

关于android - 工具栏不会隐藏在列表滚动中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34405591/

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