2013-01-31 19 views
5

मैं एंड्रॉइड प्रोजेक्ट पर काम कर रहा हूं और मुझे कोई ओवरलैपिंग किए बिना किसी सूचीदृश्य के नीचे स्क्रीन के नीचे दिखाए जाने वाले विज्ञापन को प्राप्त करने में समस्या हो रही है।सूची दृश्य को ओवरलैप किए बिना नीचे दिए गए विज्ञापन को प्रदर्शित करना

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

नीचे

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
    android:layout_width="match_parent" 
    android:layout_height="fill_parent" 
    android:background="@color/black" 
    android:orientation="vertical" > 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal"> 
    <TextView android:id="@+id/password_noRecords" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:layout_gravity="center" 
     android:text="There are currently\nno saved logins" 
     android:textSize="20dp" 
     android:textStyle="bold|italic"/> 
    <ListView 
     android:id="@android:id/list" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 
    </ListView> 
    <Button android:id="@+id/password_clearSearch" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/password_clear_search" 
     android:layout_alignParentBottom="true" 
     android:visibility="gone"/> 
    </LinearLayout> 
    <com.google.ads.AdView android:id="@+id/adView" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_horizontal" 
     android:layout_alignParentBottom="true" 
     android:gravity="center_horizontal" 
     ads:adUnitId="a14d6125d95c70b" 
     ads:adSize="BANNER" 
     ads:testDevices="TEST_EMULATOR, 015d1884222bfe01"/> 
</RelativeLayout> 

मैं कई अलग अलग तरीकों है, यह सब रिश्तेदार लेआउट के अंदर होने के बजाय एक और रेखीय लेआउट होने, नहीं होने संरेखित माता पिता नीचे = सच है, लेकिन फिर यह मेरे एक्सएमएल लेआउट के प्रति है सूची दृश्य के शीर्ष पर जो कुछ भी है, ओवरलैपिंग सूची के शीर्ष पर बैठता है।

आपकी सहायता के लिए धन्यवाद।

उत्तर

11

आप आधार के रूप में केवल एक LinearLayout का उपयोग कर (RelativeLayout से छुटकारा पाने के) और अपने ListView पर android:layout_weight संपत्ति का उपयोग करके इसे ठीक कर सकते हैं। उदाहरण:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 
    <TextView android:id="@+id/password_noRecords" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:layout_gravity="center" 
     android:text="There are currently\nno saved logins" 
     android:textSize="20dp" 
     android:textStyle="bold|italic"/> 
    <ListView 
     android:id="@android:id/list" 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" /> 
    <Button android:id="@+id/password_clearSearch" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/password_clear_search" 
     android:layout_alignParentBottom="true" 
     android:visibility="gone"/> 
    <com.google.ads.AdView android:id="@+id/adView" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_horizontal" 
     android:gravity="center_horizontal" 
     ads:adUnitId="a14d6125d95c70b" 
     ads:adSize="BANNER" 
     ads:testDevices="TEST_EMULATOR, 015d1884222bfe01"/> 
</LinearLayout> 

ध्यान दें कि ListViewandroid:layout_height="0dp" और android:layout_weight="1" है। यह अन्य तत्वों को LinearLayout में रखने के बाद छोड़े गए किसी भी स्थान को भरने के लिए विस्तारित करने के लिए कहता है।

+1

धन्यवाद android:layout_below="@id/linear_layout" जोड़ने का प्रयास करें, इस उम्र के लिए मुझे गुस्सा दिलाना किया गया है – Boardy

+1

मदद :) के लिए धन्यवाद – Gattsu

0

अपने LinearLayout को android:id="@+id/linear_layout" जोड़ने और भी आपकी मदद के लिए करने के लिए <com.google.ads.AdView ... />