2016-02-24 22 views
6

मेरे पास टैबलाउट में एक खंड xml है। TabLayout CollapsingToolbar लेआउट में है जो TabLayout में Fragments की सामग्री को स्क्रॉल करते समय ध्वस्त हो जाता है। मेरे पास एक टुकड़ा है जहां मुझे रीसाइक्लिंग व्यू के ऊपर टेक्स्टव्यू की आवश्यकता है।NestedScrollview + TextView + RecyclerView

अगर मैं लेआउट नीचे के रूप में this question I asked before से लिया है:

<LinearLayout> 
    <NestedScrollView 
     <TextView> 
     </TextView> 
    </NestedScrollView> 
    <View> 
    </View> 
    <RecyclerView> 
    </RecyclerView> 
</LinearLayout> 

ठीक काम करता है, जब तक कि यह TextView भरता इतनी सारी सामग्री में है या स्क्रीन के सबसे तक ले जाता है, RecyclerView का उपयोग कर समाप्त होता है ध्यान में रखते हुए शेष अंतरिक्ष प्रदर्शित करने के लिए:

|------------------| 
|<TextView-------->| 
|<---------------->| 
|<---------------->| 
|<---------------->| 
|<---------------->| 
|</TextView------->| 
|<RecyclerView---->| 
|</RecyclerView--->| 
|__________________| 

तो recyclerview न्यूनतम अंतरिक्ष के साथ छोड़ दिया है देखा जाना चाहिए। यदि टेक्स्टव्यू पूरी स्क्रीन लेता है, तो रीसाइक्लर व्यू बस प्रदर्शित नहीं होता है।

this SO Question से लिया तो लेआउट है:

<FrameLayout> 
    <NestedScrollView 
     <TextView> 
     </TextView> 
    </NestedScrollView> 
    <View> 
    </View> 
    <RecyclerView> 
    </RecyclerView> 
</FrameLayout> 

केवल recyclerView प्रदर्शित करता है और TextView सिर्फ अस्तित्वहीन है।

तो लेआउट है:

<NestedScrollView> 
    <LinearLayout 
     <TextView> 
     </TextView> 
     <View> 
     </View> 
     <RecyclerView> 
     </RecyclerView> 
    </LinearLayout> 
</NestedScrollView> 

TextView बस चलता, RecyclerView या नहीं में सामग्री है या नहीं।

मैं कैसे TextView स्क्रॉल खिड़की के बाहर पर्याप्त recyclerview प्रकट करने के लिए तो स्क्रीन इस से जा सकते हैं हो सकता है:

|------------------| 
|<TextView-------->| 
|<---------------->| 
|<---------------->| 
|<---------------->| 
|<---------------->| 
|</TextView------->| 
|<RecyclerView---->| 
|</RecyclerView--->| 
|__________________| 

यह करने के लिए:

|------------------| 
|<---------------->| 
|</TextView------->| 
|<RecyclerView---->| 
|<---------------->| 
|<---------------->| 
|<---------------->| 
|<---------------->| 
|</RecyclerView--->| 
|__________________| 

मेरा वर्तमान एक्सएमएल कोड जहां केवल RecyclerView दिखाता है और TextView नहीं:

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout 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="wrap_content" 
      android:background="@color/white" 
      app:layout_behavior="@string/appbar_scrolling_view_behavior"> 


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

    <android.support.v4.widget.NestedScrollView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

     <TextView 
      android:id="@+id/item_shipping_shipping_description" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="start|left" 
      android:padding="@dimen/margin_16" 
      app:layout_behavior="@string/appbar_scrolling_view_behavior"/> 
    </android.support.v4.widget.NestedScrollView> 

    <View 
     android:id="@+id/line43" 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/line_height" 
     android:background="@color/light_gray" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"/> 

    </LinearLayout> 


    <android.support.v7.widget.RecyclerView 
     android:id="@+id/item_shipping_fragment_recyclerview" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@color/white" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"/> 
</FrameLayout> 
+0

यकीन नहीं है, लेकिन match_parent करने और framelayout की ऊंचाई भी wrap_content है recycler देखने के लेआउट ऊंचाई निर्धारित करके की कोशिश तो यह बदलकर कोशिश साथ ही या दोनों –

+0

ठीक है मैंने कोशिश की है, दोनों मैच_पैरेंट पर सेट करें, सब कुछ हुआ था कि RecyclerView एकमात्र दृश्य था जो प्रदर्शित हुआ था। मैं LinearLayout को FrameLayout और उस दिखाई दे रही थी TextView – x10sion

+0

आप तो केवल एक TextView है तुम क्यों nestedscrollview में TextView डाल दिया है केवल दृश्य बदल की कोशिश की? scrollview –

उत्तर

1

मेरे मुद्दे के लिए मेरे पास एकमात्र फिक्स था जो प्रोग्राम को घोंसला वाले स्क्रॉल व्यू के भीतर प्रोग्रामेटिक रूप से घोंसला बनाना था। मैं रीसाइक्लिंग व्यू और नेस्टेडस्क्रॉलव्यू का एक साथ उपयोग करने में सक्षम नहीं था।

+0

खैर मैं सही लेआउट मैं तुम्हें दे दी है साथ यह करने के लिए कर रहा था करने देगा। या तुमने कोशिश की? – meltedspark

+0

हाँ यह काम करता है, लेकिन मैं फिर स्क्रीन के एक ही खंड पर 2 अलग स्क्रॉल क्षेत्रों है, और है कि मैं है एक टूट उपकरण पट्टी इसलिए यदि मैं या तो स्क्रॉल क्षेत्र में स्क्रॉल के शीर्ष पर उपकरण पट्टी पतन होता है और बस इसे कठिन बना स्क्रीन ब्राउज़ करने के लिए। आपकी सहायता के लिए धन्यवाद – x10sion

+0

इसलिए मैंने आपके मूल प्रश्न का उत्तर दिया, क्या आपको नहीं लगता कि मैं बक्षीस के लायक हूं? एफवाईआई, बाउंटी स्टार्टर को बक्षीस नहीं मिल सकता है। – meltedspark

0
फ्रेम लेआउट के बजाय

verticle उन्मुखीकरण के साथ LinearLayout लेने के लिए और एक और LinearLayout में recyclerview डाल: दोनों बच्चे लेआउट के

<LinearLayout orientation=verticle > 


    <LinearLayout 
     > 

    <android.support.v4.widget.NestedScrollView> 

     <TextView/> 

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

    <View 
     /> 

    </LinearLayout> 

    <LinearLayout> 
     <android.support.v7.widget.RecyclerView/> 
    </LinearLayout> 

</LinearLayout> 

लेआउट ऊंचाई wrap_content करने के लिए एक वजन जोड़ने के लिए

+0

हाय nestedscrollview से हटाने, ऊर्ध्वाधर स्क्रॉल अभ्यस्त काम करते हैं,, लेकिन वह फ्लॉप या तो काम, TextView मैं के साथ अब परीक्षण कर रहा हूँ में पर्याप्त सामग्री मौजूद है स्क्रॉल करने के लिए लेकिन जब यह तक पहुँचता है TextView RecyclerView के अंत – x10sion

+0

पोस्ट अपने जावा कोड –

+0

इस तथ्य यह है कि सब कुछ ठीक काम करता है अगर TextView अच्छा और छोटा है की वजह से एक जावा कोड मुद्दा नहीं है दिखाई नहीं देता है। RecyclerView पर्याप्त जगह – x10sion

6

कोशिश सेट किया जाना चाहिए दोनों लेआउट के लिए।
उदाहरण के लिए, अगर आप चाहते हैं कम या RecyclerView भाग के बराबर होना TextView हिस्सा:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 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"> 

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

     <android.support.v4.widget.NestedScrollView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <TextView 
       android:id="@+id/item_shipping_shipping_description" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_gravity="start|left" 
       android:padding="@dimen/margin_16"/> 
     </android.support.v4.widget.NestedScrollView> 

     <View 
      android:id="@+id/line43" 
      android:layout_width="match_parent" 
      android:layout_height="@dimen/line_height" 
      android:background="@color/light_gray"/>  
    </LinearLayout> 

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

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/item_shipping_fragment_recyclerview" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"/> 
    </LinearLayout> 
</LinearLayout> 

इस तरह TextView लेआउट युक्त पता चल जाएगा कि यह एक हाथ पर सामग्री लपेट चाहिए, लेकिन एक ही वजन RecyclerView दूसरी तरफ है और यह उनके बीच सबसे छोटा ले जाएगा।

+0

में स्क्रॉल करने योग्य डेटा के साथ एक recyclerview है एक TextView बिंदु जहां यह बंद स्क्रीन और फिर इसे नीचे चला जाता है के लिए पाठ से भरा है है लेकिन टेक्स्टव्यू में सामग्री के साथ क्या होता है जब यह आधे से अधिक स्क्रीन लेता है, तो क्या यह पाठ के निचले भाग में कटौती नहीं करेगा? – x10sion

+0

नहीं, ऐसा नहीं होगा क्योंकि TextView NestedScrollView के साथ लपेटा गया है। मैंने इस लेआउट का परीक्षण किया है, मेरे लिए काम करता है। – meltedspark

+0

ठीक है, मैं इसे आजमाइए और आप जानते हैं – x10sion

0

आप CoordinatorLayout का उपयोग स्क्रॉल ReciclerView पर TextView को छिपाने के लिए कर सकते हैं:

यहाँ आसान tutorial.

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