2017-02-27 11 views
2

私はtoolbarのカスタムとBottomSheetの両方の永続性を持つアプリケーションレイアウトを持っています。どちらもCoordinatorLayoutの中にあります。下の永続的なボトムシート

ボタンをクリックすると、BottomSheetが表示されます。現在、シートはフルスクリーンで表示され、toolbarをオーバーレイしています。アプリのテーマをTheme.AppCompat.Light.DarkActionBarに設定すると、BottomSheetActionBar以下になりますが、バーをカスタマイズすることはできません。

persententの高さを制限する方法はありますかBottomSheetフルスクリーン - ActionBar高さですか?

これはここactivity_main.xml

<android.support.design.widget.CoordinatorLayout 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:attrs="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.test.MainActivity"> 

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

    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     app:elevation="20dp" 
     android:elevation="20dp" 
     android:layout_height="?attr/actionBarSize"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      app:elevation="20dp" 
      android:elevation="20dp" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary"/> 
    </android.support.design.widget.AppBarLayout> 
    </LinearLayout> 
    <include layout="@layout/bottom_sheet_additem"/> 
</CoordinatorLayout> 

に自分のコードである左側のsheet_bottom.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/bottomSheetLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/colorAccent" 
    app:behavior_hideable="true" 
    app:behavior_peekHeight="0dp" 
    android:fitsSystemWindows="true" 
    app:layout_behavior="@string/bottom_sheet_behavior"> 

    <TextView 
     android:id="@+id/bottomsheet_text" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:text="Lorem Ipsum Dolor..." 
     android:textColor="#FFFFFF" /> 
</RelativeLayout> 

Screenshot のコード画像がToolbar下に停止BottomSheetを示している - です現在のコードでは動作しません。現在、それは右の写真のように見えます。

+0

のあなたはスクリーンショットをアップロードすることができますか? –

+0

質問に追加されたスクリーンショット - EDIT – nor0x

+0

レイアウトの高さを下からツールバーに設定し、下のシートを子にして親の高さ(新しいレイアウト)に合わせて設定してみましょう。 –

答えて

1

私は同じ問題を抱えていました。それはあまりにもあなたのために働いていた場合、私に教えてください

<android.support.design.widget.CoordinatorLayout 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:attrs="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.test.MainActivity"> 

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

     <android.support.design.widget.AppBarLayout 
      android:layout_width="match_parent" 
      app:elevation="20dp" 
      android:elevation="20dp" 
      android:layout_height="?attr/actionBarSize"> 

      <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      app:elevation="20dp" 
      android:elevation="20dp" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary"/> 
     </android.support.design.widget.AppBarLayout> 
    </LinearLayout> 

    <android.support.design.widget.CoordinatorLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginTop="56dp"> 

     <include layout="@layout/bottom_sheet_additem"/> 

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

</CoordinatorLayout> 

は、あなたのこのようなmarginTopであなたのactivity_main.xml内の別のCoordinatorLayout、内側に含める置くようにしてください。

私たちは、アプリを使用することができます
0

:layout_behavior代わりに、固定の高さ

<android.support.design.widget.CoordinatorLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

    <include layout="@layout/bottom_sheet_additem"/> 

</android.support.design.widget.CoordinatorLayout> 
関連する問題