【发布时间】:2016-12-16 09:48:19
【问题描述】:
有很多很好的教程使用NestedScrollView 讨论BottomSheet。但是在我使用当前的支持库版本 24.2.1 进行尝试后,我花了几天的时间才知道为什么我的包含顶部填充。
这是我的 Activity 的布局 xml:
<android.support.design.widget.CoordinatorLayout 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:fitsSystemWindows="true"
tools:context=".ui.MainActivity">
<!-- AppBar -->
<include
android:id="@+id/appBar"
layout="@layout/app_bar_layout_with_tab"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabPager="@{tabPager}" />
<!-- Content -->
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeRefresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
<!-- [START] BottomSheet -->
<include
android:id="@+id/bottomSheetMain"
layout="@layout/fragment_bottom_sheet_song"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:behavior_hideable="false"
app:behavior_peekHeight="0dp"
app:layout_behavior="@string/bottom_sheet_behavior" />
<!-- [END BottomSheet] -->
</android.support.design.widget.CoordinatorLayout>
还有BottomSheet的布局fragment_bottom_sheet_song.xml:
<android.support.v4.widget.NestedScrollView 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/bgBottomSheetPlayer">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
android:id="@+id/bottomSheetPlayer"
layout="@layout/view_bottom_sheet_player_dark"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:playAction="@{playAction}"
app:playObject="@{playSong}" />
<include
android:id="@+id/bottomSheetContent"
layout="@layout/view_action_detail_song"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:playSong="@{playSong}"
app:songActionHandler="@{songActionHandler}" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
为什么会有顶部填充?我该如何解决这个问题?
谢谢。
【问题讨论】:
标签: android android-support-library android-support-design bottom-sheet