2016-04-15 4 views
14

私は既に100dpに設定されたピークの高さでボトムシートレイアウトを示しました。しかし、どのようにして私のボトムシートを500dpにのみ拡大することができますか?これは私のサンプルレイアウトです:アンドロイドサポートデザインのボトムシートで最大拡張高さを設定する方法は?

私の質問に加えて
<android.support.design.widget.CoordinatorLayout 
android:id="@+id/coordinator" 
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"> 

<fragment xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/map" 
    android:name="com.google.android.gms.maps.SupportMapFragment" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".MapsActivity" /> 

<android.support.v4.widget.NestedScrollView 
    android:id="@+id/design_bottom_sheet" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#000000" 
    app:behavior_hideable="true" 
    app:behavior_peekHeight="100dp" 
    app:layout_behavior="android.support.design.widget.BottomSheetBehavior"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="100dp" 
      android:layout_marginBottom="5dp" 
      android:background="#e444ff" /> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="100dp" 
      android:layout_marginBottom="5dp" 
      android:background="#e444ff" /> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="100dp" 
      android:layout_marginBottom="5dp" 
      android:background="#e444ff" /> 

    </LinearLayout> 

</android.support.v4.widget.NestedScrollView> 

<android.support.design.widget.FloatingActionButton 
    android:id="@+id/fab" 
    android:layout_margin="@dimen/activity_horizontal_margin" 
    app:layout_anchor="@+id/design_bottom_sheet" 
    app:layout_anchorGravity="top|right|end" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" /> 

</android.support.design.widget.CoordinatorLayout> 

、どのように私は、底面シート上下にドラッグするからユーザーを禁止することができますか?

答えて

12

ちょうどあなたNestedScrollViewが500dpするためlayout_heightを設定し、全画面表示がシンプルである上に移動からのボトムシートを停止するために、また、あなたはおそらく、あなたがしたくない場合は、それはlayout_gravity="bottom"

<android.support.v4.widget.NestedScrollView 
    android:id="@+id/design_bottom_sheet" 
    android:layout_width="match_parent" 
    android:layout_height="500dp" 
    android:background="#000000" 
    android:layout_gravity="bottom" 
    app:behavior_hideable="true" 
    app:behavior_peekHeight="100dp" 
    app:layout_behavior="android.support.design.widget.BottomSheetBehavior"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="100dp" 
      android:layout_marginBottom="5dp" 
      android:background="#e444ff" /> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="100dp" 
      android:layout_marginBottom="5dp" 
      android:background="#e444ff" /> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="100dp" 
      android:layout_marginBottom="5dp" 
      android:background="#e444ff" /> 

    </LinearLayout> 

</android.support.v4.widget.NestedScrollView> 

だ設定したいですドラッグ可能にするには、behavior_peekHeightlayout_heightを同じ値に設定する必要があります。

そしてドラッグダウンしているからビューを停止するには、偽

幸運と幸せコーディングにちょうどこの設定behavior_hideableフラグです!

+1

いいですよ!それらはかなり巧妙な解決策です。どうもありがとうございました! –

+0

あなたは何かを忘れてしまったので、私たちはapp:behavior_hideableをfalseに設定する必要があります。そのため、下のシートが引き下げられることを確認します –

+1

これは残念なことに底面シートの高さを修正しませんでした。 ! – abat

関連する問題