2014-09-19 96 views
0

我嘗試添加AdMob廣告橫幅(頂部)的主要活動(我的應用主屏幕) 但我面對的小問題至極是AdMob廣告重疊的TextViewAdMob廣告重疊的TextView

這是我的主要活動xml代碼

我是新手!

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:ads="http://schemas.android.com/apk/res-auto"  
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_above="@+id/adView" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_top_margin" 

    tools:context="${relativePackage}.${activityClass}" > 
    <com.google.android.gms.ads.AdView android:id="@+id/adView" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         ads:adUnitId="ca-app-pub-xxxxxxxxx/xxxxxx" 
         ads:adSize="BANNER"/> 

    <LinearLayout 
     android:id="@+id/linearLayoutHeader" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <!-- First header line --> 
     <TextView android:id="@+id/header_priority" 
      android:layout_width="31dp" 
      android:layout_height="wrap_content" 
      android:textColor="#00F" 
      android:gravity="center" 
      android:textSize="@dimen/font_size_tiny" 
      android:text="@string/pri_label" 
      /> 

     <!-- First header line --> 
     <TextView android:id="@+id/header_item" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textColor="#00F" 
      android:textSize="@dimen/font_size_tiny" 
      android:text="@string/desc_label" 
      /> 

    </LinearLayout> 

    <ListView 
     android:id="@+id/lvItems" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_above="@+id/llPriority" 
     android:layout_below="@+id/linearLayoutHeader" > 

    </ListView> 

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

     <EditText 
      android:id="@+id/etPriority" 
      android:layout_width="60dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:ems="10" 
      android:hint="@string/hint_priority" 
      android:inputType="number" 
      android:text="@string/num_1" /> 

     <EditText 
      android:id="@+id/tvItemText" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="3" 
      android:ems="10" 
      android:hint="@string/add_hint"> 
      <requestFocus /> 
     </EditText> 

     <Button 
      android:id="@+id/btnAdd" 
      android:layout_width="85dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="2" 
      android:onClick="onClickAddItem" 
      android:text="@string/add_button_label" /> 
    </LinearLayout> 

</RelativeLayout> 

回答

1

是的,RelativeLayout允許覆蓋,但在RelativeLayout中,您也可以排列視圖元素的對齊。只要找出與您的AD瀏覽重疊視圖元素的ID和下面的屬性添加到您的AdView(我假設它與linearLayoutHeader重疊)

android:layout_above="@+id/linearLayoutHeader" 

您(或其他人是在同一個項目的工作? )實際上已經利用這些屬性來排列視圖。研究例如下面的代碼部分;-)

<ListView 
    android:id="@+id/lvItems" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_above="@+id/llPriority" 
    android:layout_below="@+id/linearLayoutHeader" > 

</ListView> 
+0

不是我所做的。但你幫了我很多。謝謝! – 2014-09-21 12:09:55

0

這是因爲根佈局是一個允許重疊的相對佈局,所以您使用的其他佈局是線性的,用於堆棧控件。

+0

所以我怎麼做?即時通訊新手,因爲你可以看到 – 2014-09-19 22:36:31

+0

RelativeLayout - > LinearLayout,但你真的應該搜索Android佈局教程。 – user114111121 2014-09-19 23:21:11