使用CoordinatorLayout和AppBarLayout還有更多問題。CoordinatorLayout/AppBarLayout ExpandableListView被渲染出屏幕
我正試圖實現基本功能,讓工具欄滾動屏幕時向下滾動,並在滾動時返回到屏幕上。
但是,我目前的設置顯示出一個問題:不僅工具欄不滾動,ListView似乎在屏幕底部渲染。它幾乎就像被AppBarLayout高度所抵消一樣。
下面是說明這一問題的GIF,請注意最後一個項目被切斷還滾動條是關閉屏幕:
我的佈局是非常標準:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:background="@color/background">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:background="@color/orange"
app:layout_scrollFlags="scroll|enterAlways"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeToRefresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<ExpandableListView
android:id="@+id/listView"
android:groupIndicator="@android:color/transparent"
android:layout_width="match_parent"
android:dividerHeight="0px"
android:layout_height="match_parent"/>
</android.support.v4.widget.SwipeRefreshLayout>
</android.support.design.widget.CoordinatorLayout>
看一看我的回答的讓我知道它的工作 – waleedsarwar86