Reputation: 2731
I'm using a BottomSheetDialogFragment however when I show it, part of it is being cut off at the bottom. Why isn't it fully inflating and how can I fix this?
Heres the full layout and usage:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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="wrap_content">
<TextView
android:id="@+id/fragplaces_app_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="12dp"
android:paddingTop="16dp"
android:paddingEnd="12dp"
android:paddingBottom="16dp"
android:text="test"
android:textColor="@color/colorWhite"
android:textStyle="bold"
app:layout_constraintTop_toTopOf="parent"
android:background="@drawable/background_top_round_corners_blue"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/fragnearme_recycler"
android:layout_width="match_parent"
android:layout_height="350dp"
android:background="@color/backgroundColor"
android:paddingBottom="8dp"
android:scrollbars="vertical"
app:layout_constraintTop_toBottomOf="@+id/fragplaces_app_name"
app:layout_constraintBottom_toTopOf="@+id/send_msg_layout"/>
<RelativeLayout
android:id="@+id/send_msg_layout"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@color/backgroundColor"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:paddingBottom="8dp">
<ImageView
android:id="@+id/btn_emoji"
android:layout_width="wrap_content"
android:layout_height="match_parent"
app:srcCompat="@drawable/ic_grey_smiley_24dp"
android:paddingStart="16dp"
android:paddingEnd="16dp"/>
<EditText
android:id="@+id/challengeroom_et_sendmessage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toEndOf="@id/btn_emoji"
android:background="@drawable/background_chat_send_message"
android:gravity="center_vertical"
android:hint="Type a message"
android:inputType="text"
android:maxLines="1"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:textColorHint="@color/defaultTextColor"
android:textSize="14sp" />
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Usage:
BottomSheetDialogFragment chatFragment = new ChatFragment();
chatFragment.show(getSupportFragmentManager(), Constants.FRAGMENT_CHAT);
I've tried changing the parent constraint layout height to match_parent
and have also tried setting it to a defined height like 500dp, however it still doesn't work.
Upvotes: 1
Views: 2310
Reputation: 2731
Adding <item name="behavior_peekHeight">500dp</item>
in my BottomSheetDialog's style fixed the issue.
<style name="BottomSheetRoundedCorners" parent="Widget.Design.BottomSheet.Modal">
<item name="android:background">@drawable/background_top_round_corners</item>
<item name="behavior_peekHeight">500dp</item>
</style>
<style name="AppBottomSheetDialogTheme" parent="Theme.Design.Light.BottomSheetDialog">
<item name="bottomSheetStyle">@style/BottomSheetRoundedCorners</item>
<item name="behavior_draggable">false</item>
</style>
and using it in my main app theme:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="bottomSheetDialogTheme">@style/AppBottomSheetDialogTheme</item>
</style>
Credits to this answer:
https://stackoverflow.com/a/35720641/11110509
Upvotes: 2