2016-06-30 6 views
5

में अंतिम आइटम देखने की अनुमति नहीं देता है, मेरे पास है जिसमें मेरे पास RecyclerView और LinearLayoutAdView के अंदर है। RecyclerView में कई आइटम हैं और जब मैं उन्हें स्क्रीन में दिखाने में असमर्थ था, तो मुझे उन्हें देखने के लिए नीचे स्क्रॉल करना पड़ा था, लेकिन अब मैंने LinearLayout को AdView के साथ स्क्रीन के नीचे से नीचे स्क्रॉल किया था और मैं ' मैं RecyclerView की अंतिम वस्तु को देखने में सक्षम नहीं हूं। मैं LinearLayout को नीचे से जोड़ रहा हूं लेकिन ऐसा लगता है कि यह RecyclerView से ऊपर है और मुझे स्क्रीन में आइटम दिखाने के लिए RecyclerView चाहिए लेकिन LinearLayout के पीछे नहीं। क्या यह संभव है?नीचे से जोड़ा गया एडव्यू मुझे रीसाइक्लर्विव

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
xmlns:ads="http://schemas.android.com/apk/res-auto"> 

<android.support.v7.widget.RecyclerView 
    android:id="@+id/rvGeneric" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:scrollbars="vertical"> 
</android.support.v7.widget.RecyclerView> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:gravity="center"> 

    <com.google.android.gms.ads.AdView 
     android:id="@+id/adViewBaseRefresh" 
     android:layout_width="fill_parent" 
     android:layout_height="53dp" 
     ads:adSize="BANNER" 
     ads:adUnitId="@string/banner_ad_unit_id" 
     android:layout_marginBottom="3dp"> 
    </com.google.android.gms.ads.AdView> 

</LinearLayout> 

+0

के लिए क्या अपने आप कर के रूप में अच्छी तरह से LinearLayout करने के लिए इसे बदल सकते हैं, और फिर टी के लिए वजन सेट वह वजन – Geoff

+0

पर वजन देखें @ वजन कम करें? मैं उसको कैसे करू? – Nahue

+0

एंड्रॉइड: layout_weight = "0.1" – Geoff

उत्तर

3

एक रिश्तेदार लेआउट की जरूरत है "सापेक्ष" रिश्तों एक्सएमएल में परिभाषित:

यहाँ लेआउट के लिए मेरे एक्सएमएल है। चूंकि आपके पास कोई नहीं है (नीचे रैखिक लेआउट को संरेखित करने के अलावा), परिणाम एलएल और रीसाइक्लिंग व्यू ओवरलैपिंग है। रेखीय लेआउट

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:ads="http://schemas.android.com/apk/res-auto"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/ll_ad" 
     android:layout_alignParentBottom="true" 
     android:gravity="center"> 

     <com.google.android.gms.ads.AdView 
      android:id="@+id/adViewBaseRefresh" 
      android:layout_width="fill_parent" 
      android:layout_height="53dp" 
      ads:adSize="BANNER" 
      ads:adUnitId="@string/banner_ad_unit_id" 
      android:layout_marginBottom="3dp"> 
     </com.google.android.gms.ads.AdView> 

    </LinearLayout> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/rvGeneric" 
     android:layout_above="@id/ll_ad" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:scrollbars="vertical"/> 

</RelativeLayout> 
+0

हाय, उत्तर देने के लिए धन्यवाद! मैंने अभी कोशिश की है लेकिन यह काम नहीं किया है। और क्या गलत हो सकता था? – Nahue

+0

जेनॉफ का लिनियरलाउट का उत्तर शायद आसान है ... लेकिन मैंने रिलेवेटिवआउट के लिए काम करने के लिए भी मेरा संपादन किया। Linearlayout अब पहले परिभाषित किया गया है, फिर RecyclerView - RelativeLayout सामग्री सही होने के लिए मुश्किल हो सकती है। – FishStix

+0

यह एक पूरी तरह से काम किया, धन्यवाद! – Nahue

0

को layout_below = "@ आईडी/rvGeneric" इसके लिए मैं व्यक्तिगत रूप से नीचे की तरह एक LinearLayout का उपयोग करेंगे::

लाइन एंड्रॉयड जोड़े

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:ads="http://schemas.android.com/apk/res-auto" 
    tools:context="com.example.geoff.stackoverflowtesting.MainActivity" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 
    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:paddingBottom="@dimen/activity_vertical_margin" 
     android:paddingLeft="@dimen/activity_horizontal_margin" 
     android:paddingRight="@dimen/activity_horizontal_margin" 
     android:paddingTop="@dimen/activity_vertical_margin"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 
      <TextView 
       android:id="@+id/rvGeneric" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:text="TESTING2" 
       android:background="#FFF000" 
       android:textSize="200dp" 
       android:scrollbars="vertical"> 
      </TextView> 
     </LinearLayout> 
    </ScrollView> 
    <TextView 
     android:id="@+id/adViewBaseRefresh" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="TESTING" 
     android:textSize="30dp" 
     android:textColor="#FFF000" 
     android:background="#000000" 
     android:layout_marginBottom="3dp" 
     android:layout_weight="0.1"> 
    </TextView> 
</LinearLayout> 

यदि आप विशेष रूप से फिर एक RelativeLayout उपयोग करना चाहते हैं:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:ads="http://schemas.android.com/apk/res-auto" 
    tools:context="com.gfaiers.layoutexamples.MainActivity" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 
    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:paddingBottom="@dimen/activity_vertical_margin" 
     android:paddingLeft="@dimen/activity_horizontal_margin" 
     android:paddingRight="@dimen/activity_horizontal_margin" 
     android:paddingTop="@dimen/activity_vertical_margin"> 
     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 
      <android.support.v7.widget.RecyclerView 
       android:id="@+id/rvGeneric" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:scrollbars="vertical"> 
      </android.support.v7.widget.RecyclerView> 
     </LinearLayout> 
    </ScrollView> 
    <com.google.android.gms.ads.AdView 
     android:id="@+id/adViewBaseRefresh" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     ads:adSize="BANNER" 
     ads:adUnitId="@string/banner_ad_unit_id" 
     android:layout_marginBottom="3dp"> 
    </com.google.android.gms.ads.AdView> 
</RelativeLayout> 
+0

हाय जियोफ़, दोनों कोड काम नहीं करते हैं = ( – Nahue

+0

मुझे एंड्रॉइड स्टूडियो को बूट करने दें, मैं उन्हें एक परीक्षा दूंगा और इसे आपके लिए प्राप्त करूंगा। उह, इसके लिए एक बड़ा अपडेट मिला ... मुझे एक जबकि – Geoff

+0

देरी के लिए माफ़ी, बड़े अपडेट करना पड़ा। मैंने अभी # 1 का परीक्षण किया है और यह मेरे लिए काम करता है, मैंने यह दिखाने के लिए कोड अपडेट किया है कि मुझे इसके लिए क्या मिला है। जैसा कि आप देख सकते हैं कि आप इसे चलाते हैं या नहीं , काला + पीले परीक्षण टेक्स्टव्यू को नीचे पिन किया गया है और जितना आवश्यक हो उतना स्थान लेता है, बाकी को स्क्रॉलव्यू पर देता है। आप अभी भी ऊपर की चीज़ों की सभी सामग्री देख सकते हैं क्योंकि आपको बस खींचने/नीचे स्क्रॉल करने की आवश्यकता है। – Geoff

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