13

काम नहीं करता है मैंने कॉर्डिनेटरलायआउट के साथ नई सपोर्ट डिज़ाइन लाइब्रेरी को आजमाया है, लेकिन मुझे बच्चे के विचारों को एंकर करने में समस्याएं आ रही हैं। मेरे लेआउट वर्तमान में इस तरह दिखता है:CoordinatorLayout layout_anchor

<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/coordinator_layout" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<android.support.design.widget.AppBarLayout 
    android:id="@+id/appbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

    <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/ThemeOverlay.AppCompat.Light" 
     app:layout_scrollFlags="enterAlways" /> 

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

<android.support.v7.widget.RecyclerView 
    android:id="@+id/recyclerview" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_anchor="@id/toolbar" 
    app:layout_anchorGravity="bottom"/> 

<android.support.design.widget.FloatingActionButton 
    android:id="@+id/fab" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginBottom="16dp" 
    android:layout_marginEnd="16dp" 
    android:layout_marginRight="16dp" 
    android:src="@drawable/ic_fab_add" 
    android:onClick="onAddPlayerClick" 
    android:layout_gravity="bottom|end" 
    app:elevation="4dp" 
    app:borderWidth="0dp"/> 

जब RecyclerView सूची भरी हुई है, पहला आइटम कार्रवाई बार ओवरलैप हो जा रहा है। मैं ऐप मानता हूं: layout_anchor ठीक से काम नहीं कर रहा है। मैंने पहले से ही सफलता के लिए एपबार करने के लिए इसे एंकर करने की कोशिश की है।

क्या कोई जानता है कि मैं यहां क्या गलत कर रहा हूं?

उत्तर

20

इस कोड को आज़माएं। मैं वास्तव में है कि याद आती है कि आप अपने RecyclerView

<android.support.v7.widget.RecyclerView 
     android:id="@+id/recyclerview" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"/> 

<android.support.design.widget.FloatingActionButton 
    android:id="@+id/fab" 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:layout_marginBottom="16dp" 
    android:layout_marginEnd="16dp" 
    android:layout_marginRight="16dp" 
    android:src="@drawable/ic_fab_add" 
    android:onClick="onAddPlayerClick" 
    app:elevation="4dp" 
    app:borderWidth="0dp" 
    app:layout_anchor="@id/appbar" 
    app:layout_anchorGravity="bottom|right|end" 
    android:clickable="true"/> 
+0

आह में app:layout_behavior उपयोग करने की आवश्यकता? ... धन्यवाद बहुत much.Problem हल किया। –

+0

'@ string/appbar_scrolling_view_behavior' का मान क्या है और यह व्यवहार क्यों काम करता है? – AdamMc331

+0

मैं यह भी जानना चाहता हूं – Eenvincible

संबंधित मुद्दे