2016-09-17 2 views
0
View bottomSheet = findViewById(R.id.design_bottom_sheet); 



    <?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:id="@+id/rootview" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 

    > 

    <LinearLayout 
     android:id="@+id/container" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 


     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 

      app:popupTheme="@style/MyMaterialTheme.PopupOverlay"> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:gravity="center" 
       android:orientation="horizontal" 
       android:paddingRight="16dp"> 

       <TextView 
        android:id="@+id/title" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="16dp" 
        android:layout_weight="1" 
        android:singleLine="true" 
        android:text="" 
        android:textColor="#fff" 
        android:textSize="20.4sp" 
        android:transitionName="profile" /> 

       <ImageButton 
        android:id="@+id/options" 

        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:background="@null" 


        /> 
      </LinearLayout> 

     </android.support.v7.widget.Toolbar> 


     <android.support.v7.widget.RecyclerView 
      android:id="@+id/chat_list_view" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 

      android:background="#efefef" 
      android:scrollbars="none" 
      app:reverseLayout="true" 

      app:stackFromEnd="true" /> 


    </LinearLayout> 

    <RelativeLayout 
     android:id="@+id/design_bottom_sheet" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="bottom" 

     app:behavior_hideable="true" 
     app:behavior_peekHeight="50dp" 

     app:layout_behavior="@string/bottom_sheet_behavior"> 

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

    </RelativeLayout> 

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

J'ai la disposition relative suivante qui est utilisée comme feuille de fond. Comment puis-je obtenir sa hauteur pendant une instance d'exécution. Fondamentalement, mon activité se compose d'une liste (recyclerview) et je veux garder le recyclerview au-dessus de la feuille de fond chaque fois que la feuille est affichée. RIght maintenant, il se cache derrière la feuille.Obtenez la hauteur d'une feuille de fond afin que la vue de recyclage puisse toujours rester au-dessus

Répondre

0

changer votre mise en page à ce

<?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:id="@+id/rootview" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 

     > 

     <LinearLayout 
      android:id="@+id/container" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 


      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       android:background="?attr/colorPrimary" 

       app:popupTheme="@style/MyMaterialTheme.PopupOverlay"> 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:gravity="center" 
        android:orientation="horizontal" 
        android:paddingRight="16dp"> 

        <TextView 
         android:id="@+id/title" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_marginLeft="16dp" 
         android:layout_weight="1" 
         android:singleLine="true" 
         android:text="" 
         android:textColor="#fff" 
         android:textSize="20.4sp" 
         android:transitionName="profile" /> 

        <ImageButton 
         android:id="@+id/options" 

         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:background="@null" 


         /> 
       </LinearLayout> 

      </android.support.v7.widget.Toolbar> 


      <android.support.v7.widget.RecyclerView 
       android:id="@+id/chat_list_view" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 

       android:background="#efefef" 
       android:scrollbars="none" 
       app:reverseLayout="true" 

       app:stackFromEnd="true" /> 

    <RelativeLayout 
      android:id="@+id/design_bottom_sheet" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="bottom" 

      app:behavior_hideable="true" 
      app:behavior_peekHeight="50dp" 

      app:layout_behavior="@string/bottom_sheet_behavior"> 

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

     </RelativeLayout> 
     </LinearLayout> 



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

Je l'ai fait essayer, cependant, dans ce cas 'application: behavior_hideable = "true" app: behavior_peekHeight = "50dp"' ne fonctionnent pas. Il m'avertit 'app inattendue de préfixe d'espace de nom trouvé pour relativelayout' Il gâte la hiérarchie d'origine de la mise en page de bottomsheet. Fondamentalement, la disposition de la feuille de fond doit toujours être séparée de l'autre mise en page sauf la disposition racine qui est 'coordinatorlayout' –

+0

essayez d'ajouter la mise en page parent ** RelativeLayout ** puis utilisez ** layout_above =" @ + id/design_bottom_sheet "** à votre disposition linéaire –