Reputation: 3502
I am adding a bottom sheet to my co-ordinator layout, but it is not going down(below the screen), it overlaps over the visible content on the screen. I have tried removing couple of elements but it doesn't work!
Here is the XML :
<?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/grey_200"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/fragment_detail_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="240dp"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/fragment_detail_collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:fitsSystemWindows="true"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:statusBarScrim="@android:color/transparent"
app:theme="@style/Theme.AppCompat.NoActionBar">
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/fragment_detail_collapsing_toolbar_image_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:foreground="@drawable/ripple"
android:scaleType="centerCrop"
android:scaleX="1.2"
android:scaleY="1.2"
app:layout_collapseMode="parallax"
app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"/>
<android.support.v7.widget.Toolbar
android:id="@+id/fragment_detail_toolbar"
android:layout_width="match_parent"
android:layout_height="136dp"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|enterAlways"
app:titleTextColor="@android:color/white">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/fragment_detail_title_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="156dp"
android:layout_marginRight="16dp"
android:fontFamily="sans-serif-condensed"
android:textColor="@android:color/black"
android:textSize="20sp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="156dp"
android:layout_marginTop="16dp"
android:orientation="horizontal">
<TextView
android:id="@+id/fragment_detail_date_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/date_radius"
android:gravity="center"
android:paddingBottom="2dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="2dp"
android:textColor="@android:color/white"
android:textSize="16sp"/>
<ImageView
android:layout_width="24dp"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:alpha="0.4"
android:gravity="center"
android:src="@drawable/ic_access_time_white_24dp"
android:tint="@android:color/black"/>
<TextView
android:id="@+id/fragment_detail_runtime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:gravity="center"
android:textColor="@android:color/black"
android:textSize="16sp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:orientation="horizontal">
<RatingBar
android:id="@+id/fragment_detail_vote"
style="?attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0.8"
android:isIndicator="true"
android:numStars="10"
android:progressTint="@android:color/holo_red_light"
android:stepSize="0.1"/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="@string/overview"
android:textColor="@color/colorAccent"/>
<TextView
android:id="@+id/fragment_detail_overview_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:textIsSelectable="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="@string/top_cast"
android:textColor="@color/colorAccent"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/fragment_detail_cast_reycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"/>
<Button
android:id="@+id/fragment_detail_show_more_cast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/show_more_cast"/>
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/fragment_detail_anchor_image"
android:layout_width="116dp"
android:layout_height="174dp"
android:layout_margin="16dp"
android:background="@android:color/white"
android:elevation="8dp"
android:scaleType="fitXY"
app:layout_anchor="@id/fragment_detail_app_bar_layout"
app:layout_anchorGravity="bottom"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fragment_detail_favourites_fab"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="bottom|right"
android:layout_margin="24dp"
android:clickable="true"
android:elevation="8dp"
android:src="@drawable/ic_favorite_white_48dp"
android:tint="@android:color/holo_red_light"
app:backgroundTint="@android:color/white"
app:fabSize="normal"/>
<android.support.v4.widget.NestedScrollView
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="350dp"
android:background="@android:color/white"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior">
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
Upvotes: 0
Views: 637
Reputation: 3502
Solved it by setting app:behavior_peekHeight="0dp"
(Don't know if it is the best practice, but it gets the job done)
Upvotes: 1
Reputation: 12444
you should add app:behavior_hideable="true"
to your layout, so it will look like this:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:behavior_hideable="true">
behavior_hideable: Whether this bottom sheet can be hidden by dragging it further downwards May be a boolean value, such as "true" or "false".
Source: BottomSheetBehavior
Upvotes: 1