2014-11-10 6 views
7

मैंने हाल ही में AppCompat 21 के नए घटकों और सामग्री डिज़ाइन को लागू करने के साथ गड़बड़ करना शुरू कर दिया है। वर्तमान में, मेरे पास टूलबार के साथ एक्शनबार एक्टिविटी है और मैं टेक्स्टव्यू आइटम्स के रीसाइक्लर व्यू (केवल रीसाइक्लर का परीक्षण करने के लिए) युक्त एक टुकड़ा होस्ट करने की कोशिश कर रहा हूं। मैं आइटम प्रदर्शित किया जा रहा है, लेकिन प्रत्येक दृश्य का टेक्स्ट कट जाता है और पूरे रेमंड तो जैसे टूलबार को कवर किया जाता है:फ्रैगमेंट सामग्री ओवरलेइंग टूलबार

e description here

जैसा कि आप देख सकते हैं, वहाँ तीन TextViews हैं। उनका टेक्स्ट आधा रास्ते काट दिया गया है और यह टूलबार को ओवरले कर रहा है (कोई शीर्षक मुझे नहीं पता)। TextView आइटम लेआउट एक RecyclerView लेआउट के भीतर निहित हैं, जो टुकड़े का लेआउट है। अभिभावक गतिविधि में फ़्रेमलेआउट -> टूलबार, फ़्रेमलाउट है। मैं गतिविधि के उप फ्रेमलेआउट में टुकड़ा डाल रहा हूं। यहाँ एक्सएमएल है:

रेमंड का प्रत्येक दृश्य:

<TextView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/textview" 
    android:layout_width="match_parent" 
    android:layout_height="48dp" 
    android:fontFamily="sans-serif" 
    android:paddingTop="16dp" 
    android:paddingBottom="20dp" 
    android:textSize="16sp"/> 

रेमंड लेआउट, जो टुकड़ा के लेआउट है:

<android.support.v7.widget.RecyclerView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/recycler_tasks" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="stuff.MainActivity$TaskFragment"> 
</android.support.v7.widget.RecyclerView> 

और माता पिता गतिविधि के लेआउट:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".MainActivity" 
    tools:ignore="MergeRootFrame"> 

    <android.support.v7.widget.Toolbar 
    android:id="@+id/toolbar" 
    android:layout_height="wrap_content" 
    android:layout_width="match_parent" 
    android:minHeight="?attr/actionBarSize" 
    android:background="?attr/colorPrimary" 
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/> 

    <FrameLayout 
    android:id="@+id/fragment_container" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"/> 

</FrameLayout> 

मुझे पता है कि यह कुछ आसान होना चाहिए, लेकिन मुझे थोड़ी देर के लिए इस पर फंस गया है, विभिन्न चीजों को कोई एवा नहीं इल।

उत्तर

8

शीर्ष पेरेंट के रूप में FrameLayout के बजाय RelativeLayout का उपयोग करें। फिर या layout_below के लिए खंड कंटेनर के लिए layout_above जैसी निर्भरताएं जोड़ें।

21

कृपया एप्लिकेशन को जोड़ना भूल नहीं है: layout_behavior = "@ स्ट्रिंग/appbar_scrolling_view_behavior" अपनी सामग्री लेआउट

<android.support.design.widget.CoordinatorLayout 
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"> 

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

    <android.support.v7.widget.Toolbar 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="?attr/colorPrimary" 
     app:layout_scrollFlags="scroll|enterAlways" 
     app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> 

     <android.support.design.widget.TabLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 

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

    <android.support.v4.view.ViewPager 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

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

यह सही जवाब होना चाहिए करने के लिए ... – josemigallas

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