2012-01-07 1 views
2

Я пытаюсь добавить объявления в свой макет поверх него.показ рекламы (сверху или снизу) в макете, который находится в scrollview в android

<?xml version="1.0" encoding="utf-8"?> 



<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="@drawable/bg" > 

<LinearLayout 
    android:id="@+id/ll" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:padding="5dp" > 

    <com.google.ads.AdView 
     android:id="@+id/adView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     ads:adSize="BANNER" 
     ads:adUnitId="xxxxxxxxxxxxxxxxxxxxx" 
     ads:loadAdOnCreate="true" /> 

    <TextView 
     android:id="@+id/feststatic" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:padding="3dp" 
     android:text="@string/festname" 
     android:textColor="@color/white" 
     android:textSize="22dp" /> 

    <TextView 
     android:id="@+id/festival" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:padding="3dp" 
     android:text="" 
     android:textColor="#C2DFFF" 
     android:textSize="18dp" /> 

    <TextView 
     android:id="@+id/daystatic" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:padding="3dp" 
     android:text="@string/weekday" 
     android:textColor="@color/white" 
     android:textSize="22dp" /> 

    <TextView 
     android:id="@+id/day" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:padding="3dp" 
     android:text="" 
     android:textColor="#C2DFFF" 
     android:textSize="18dp" /> 

    <TextView 
     android:id="@+id/monthstatic" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:padding="3dp" 
     android:text="@string/month" 
     android:textColor="@color/white" 
     android:textSize="22dp" /> 

    <TextView 
     android:id="@+id/month" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:padding="3dp" 
     android:text="" 
     android:textColor="#C2DFFF" 
     android:textSize="18dp" /> 

    <TextView 
     android:id="@+id/fulldatestatic" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:padding="3dp" 
     android:text="@string/date" 
     android:textColor="@color/white" 
     android:textSize="22dp" /> 

    <TextView 
     android:id="@+id/fulldate" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:padding="3dp" 
     android:text="" 
     android:textColor="#C2DFFF" 
     android:textSize="18dp" /> 

    <TextView 
     android:id="@+id/descstatic" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:padding="3dp" 
     android:text="@string/desc" 
     android:textColor="@color/white" 
     android:textSize="22dp" /> 

    <TextView 
     android:id="@+id/desc" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:padding="3dp" 
     android:text="" 
     android:textColor="#C2DFFF" 
     android:textSize="18dp" 
     android:typeface="serif" /> 
</LinearLayout> 



</ScrollView> 

Выше мой файл макета Xml, но когда я запускаю его я получаю эту ошибку "Не достаточно места, чтобы показать объявление Предпочтения: < 320, 50>, имеет: < 310, 1073741823>" I не прописали прокрутку.

Любая помощь будет оценена. Спасибо заранее.

ответ

2

Мои bad..I дал отступы для линейной компоновки ... Я удалил его, и он работал как шарм.

0

Конец файла с </ScrollView>, чуть ниже </LinearLayout

+0

Спасибо. У меня есть инструкция конца прокрутки. –

+0

Сначала попробуйте удалить все текстовые представления. если проблема по-прежнему сохраняется, это может быть объявление. – Hend

+1

Могу ли я зафиксировать объявление в нижней части экрана? –

0

От: @Hend Создать RelativeLayout в качестве родителя Scrollview. Затем добавьте вид admob как дочерний элемент RelativeLayout вместо scrollview и используйте android: layout_alignParentBottom = "true" android: layout_centerHorizontal = "true" в нем (вид admov).

<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="match_parent" > 

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" > 

     <TextView 
      android:id="@+id/textViewGeneralHeader" 
      style="@style/heading_text" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentTop="true" 
      android:layout_marginLeft="10dp" 
      android:layout_marginTop="5dp" 
      android:text="General Info" /> 

     <ImageView 
      android:id="@+id/imageViewLine1" 
      android:layout_width="fill_parent" 
      android:layout_height="1dp" 
      android:layout_below="@+id/textViewGeneralHeader" 
      android:layout_marginTop="5dp" 
      android:background="@drawable/line" /> 

     <TextView 
      android:id="@+id/textViewGenealDescription" 
      style="@style/description" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignLeft="@+id/textViewGeneralHeader" 
      android:layout_below="@+id/imageViewLine1" 
      android:layout_marginTop="10dp" 
      android:text="Description" /> 

     <ImageView 
      android:id="@+id/imageViewLine2" 
      android:layout_width="fill_parent" 
      android:layout_height="1dp" 
      android:layout_below="@+id/textViewGenealDescription" 
      android:layout_marginTop="5dp" 
      android:background="@drawable/line" /> 

     <TextView 
      android:id="@+id/textViewDisplayHeader" 
      style="@style/heading_text" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignLeft="@+id/textViewGeneralHeader" 
      android:layout_below="@+id/imageViewLine2" 
      android:layout_marginTop="5dp" 
      android:text="Display Info" /> 

     <ImageView 
      android:id="@+id/imageViewLine3" 
      android:layout_width="fill_parent" 
      android:layout_height="1dp" 
      android:layout_below="@+id/textViewDisplayHeader" 
      android:layout_marginTop="5dp" 
      android:background="@drawable/line" /> 

     <TextView 
      android:id="@+id/textViewDisplayDescription" 
      style="@style/description" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignLeft="@+id/textViewGeneralHeader" 
      android:layout_below="@+id/imageViewLine3" 
      android:layout_marginTop="10dp" 
      android:text="Description" /> 

     <ImageView 
      android:id="@+id/imageViewLine4" 
      android:layout_width="fill_parent" 
      android:layout_height="1dp" 
      android:layout_below="@+id/textViewDisplayDescription" 
      android:layout_marginTop="5dp" 
      android:background="@drawable/line" /> 
    </RelativeLayout> 
</ScrollView> 

<com.google.ads.AdView 
    android:id="@+id/adView" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_centerHorizontal="true" 
    ads:adSize="BANNER" 
    ads:adUnitId="a14e2f8fe3af5a6" 
    ads:loadAdOnCreate="true" > 
</com.google.ads.AdView></RelativeLayout>