2017-12-01 5 views
0

Ich versuche, das untere Blatt zusammen mit dem BottomNavigationview zu zeigen. But overlapping. Check HereWie setze ich das untere Blatt an die Spitze der unteren Navigationsansicht

Wie ich unteren Rand unteren Rand geben werde.

XML-Code:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/bottomSheet" 
    android:background="@android:color/white" 
    android:paddingTop="@dimen/activity_horizontal_margin" 
    app:layout_behavior="android.support.design.widget.BottomSheetBehavior" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <android.support.constraint.ConstraintLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/bottomSheetRecyclerview" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      app:layout_constraintEnd_toEndOf="parent" 
      app:layout_constraintStart_toStartOf="parent" 
      app:layout_constraintTop_toTopOf="parent" /> 
    </android.support.constraint.ConstraintLayout> 

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

Code Implementierung:

override fun openBottomDialogView() { 

     val bottomSheetView= findViewById<NestedScrollView>(R.id.bottomSheet) as NestedScrollView 
     Log.e("Bottom sheet view ",bottomSheetView.toString()) 


     dashboardBottomSheetBehaviour = BottomSheetBehavior.from(bottomSheetView) 
      dashboardBottomSheetBehaviour.isHideable=true 

     if(dashboardBottomSheetBehaviour.getState() != BottomSheetBehavior.STATE_EXPANDED) { 

      bottomSheetRecyclerview.layoutManager= LinearLayoutManager([email protected]) as RecyclerView.LayoutManager? 
      bottomSheetRecyclerview.adapter= BottomSheetDialogAdaptor([email protected], getBottomSheetitem()) 
      dashboardBottomSheetBehaviour.setState(BottomSheetBehavior.STATE_EXPANDED); 
     } 
     else { 
      closeBottomView() 
     } 
    } 

Ich versuchte, die feste Höhe von nestedscrollview zu setzen und dann Rand geben, aber das auch nicht funktioniert.

Über neue Themen Ich bin vor

fun closedBottomView(){ 
    Log.e("CLose ","Old bottom sheet") 
     dashboardBottomSheetBehaviour.state=BottomSheetBehavior.STATE_HIDDEN 
     Log.e("Final state ",dashboardBottomSheetBehaviour.state.toString()) 

} 

Hier letzte log sagt untere Blatt Zustand in STATE_SETTLING ist. Aber Rückruf sagt es im VERSTECKTEN Zustand.

Antwort

1

Versuchen Sie es mit: layout_anchor für Ihre BottomNavigationView es zu verankern, oben/unten in Ihrem BottomSheetView

app:layout_anchor="@+id/bottomSheet" --> BottomSheet view ID 
app:layout_anchorGravity="bottom|end" 

Für weitere Informationen, die Sie bei This Link

+0

Das ist mein Problem gelöst, sondern erstellt die neuen Probleme suchen. Jetzt bricht das untere Blatt nicht zusammen. –

+0

Legen Sie eine Peek-Höhe auf Ihrem BottomSheet fest ... und überschreiben Sie die Callback-Methode, um herauszufinden, in welchem ​​Status sie sich befindet. Sehen Sie dies: http: //android-er.blogspot.com/2016/06/sets-height-of -collapsed-bottom-sheet.html – rafsanahmad007

+0

Ich glaube, ich muss die Callback-Methode nicht überschreiben, da ich den Status des Blattes über den Fab ein-/ausblenden kann. –

Verwandte Themen