问题:
我正在使用 BottomSheetDialogFragment 作为我的模态底部表单,想要设置一个最大宽度,以便在平板电脑/大屏幕上,BottomSheet 不会占据整个屏幕的宽度。我该怎么处理这个问题?谢谢!
相关代码和资源:
我正在使用 BottomSheetDialogFragment 作为我的模态底部表单,想要设置一个最大宽度,以便在平板电脑/大屏幕上,BottomSheet 不会占据整个屏幕的宽度。我该怎么处理这个问题?谢谢!
相关代码和资源:
fragment_bottomsheet.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"
style="@style/BottomSheetStyle">
<GridLayout
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:alignmentMode="alignBounds"
android:columnOrderPreserved="false"
android:columnCount="3"
android:paddingTop="16dp"
android:paddingBottom="8dp"
android:paddingRight="8dp"
android:paddingLeft="8dp"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/image1"
android:text="Open"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/image2"
android:text="Save"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/image3"
android:text="Send"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/image4"
android:text="Upload"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/image5"
android:text="Share"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/iamge6"
android:text="More"/>
</GridLayout>
</android.support.design.widget.CoordinatorLayout>
res/values/styles.xml:
<style name="BottomSheetStyle">
<item name="android:layout_height">match_parent</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_gravity">center_horizontal</item>
</style>
res/values-w600dp/styles.xml:
<style name="BottomSheetStyle">
<item name="android:layout_height">match_parent</item>
<item name="android:layout_width">640dp</item>
<item name="android:layout_gravity">center_horizontal</item>
</style>
NestedScrollView
。 - ade.akinyede