2013-11-27 58 views
1

我有一个简单的布局。但我不能让它与我想放在底部的广告一起工作。这里有2个屏幕截图,有没有广告。覆盖布局底部的广告Android

没有AD

enter image description here

随着AD

enter image description here

正如你可以看到广告时,它的加载,它涵盖了两个按钮(这是相对布局)。我怎样才能做到这一点,所以当AD加载时,我的相对布局会在广告上面“碰撞”?这是我的XML。

<?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:app="http://schemas.android.com/apk/res/example.com"> 



    <com.example.touch.TouchImageView android:id="@+id/mytouchview" 
     android:layout_height="match_parent" 
     android:layout_width="match_parent" 
     android:layout_marginLeft="5dp" 
     android:layout_marginRight="5dp" 
     android:layout_marginTop="5dp" 
     android:layout_above="@+id/relat" 
     /> 




     <RelativeLayout 
      android:id="@+id/relat" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:paddingLeft="10dp" 
      android:paddingRight="10dp" 
      > 

      <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="3dp" android:layout_alignParentLeft="true" 
      android:background="@null" android:src="@drawable/previous" android:id="@+id/previous"/> 

      <TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:textSize="20sp" android:text="2/15" 
     android:id="@+id/memeNumber" android:layout_centerInParent="true" android:layout_margin="5dp"/> 


     <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="3dp" android:layout_alignParentRight="true" 
      android:background="@null" android:src="@drawable/next" android:id="@+id/next"/> 


</RelativeLayout> 



    <com.csjy.sfwn148282.AdView 
xmlns:ap="http://schemas.android.com/apk/res-auto" 
android:id="@+id/myAdView" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
ap:animation="fade" 
ap:placementType="interstitial" 
ap:banner_type="inappad" 
ap:test_mode="true" 
ap:canShowMR="false" 
android:layout_alignParentBottom="true" 


/> 

</RelativeLayout> 

编辑:

我不喜欢@Szymon劝我,但我现在面临的问题是,布局定位就是这样,直到广告加载。之后,它就像它应该那样工作。如何解决这个问题?

enter image description here

回答

2

这会为你工作。请注意,对于您声明的每个变量(即使您在除实际元素外的其他位置声明它),您只应使用@+id一次。在下面的代码中,它在android:layout_above中声明,并且仅在实际元素声明中用作@id

<?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:app="http://schemas.android.com/apk/res/example.com"> 



    <com.example.touch.TouchImageView android:id="@+id/mytouchview" 
     android:layout_height="match_parent" 
     android:layout_width="match_parent" 
     android:layout_marginLeft="5dp" 
     android:layout_marginRight="5dp" 
     android:layout_marginTop="5dp" 
     android:layout_above="@+id/relat" 
     /> 

     <RelativeLayout 
      android:id="@id/relat" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:paddingLeft="10dp" 
      android:paddingRight="10dp" 
      android:layout_above="@+id/myAdView" 
      > 

      <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="3dp" android:layout_alignParentLeft="true" 
      android:background="@null" android:src="@drawable/previous" android:id="@+id/previous"/> 

      <TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:textSize="20sp" android:text="2/15" 
       android:id="@+id/memeNumber" android:layout_centerInParent="true" android:layout_margin="5dp"/> 


      <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="3dp" android:layout_alignParentRight="true" 
      android:background="@null" android:src="@drawable/next" android:id="@+id/next"/> 


     </RelativeLayout> 



    <com.csjy.sfwn148282.AdView 
     xmlns:ap="http://schemas.android.com/apk/res-auto" 
     android:id="@id/myAdView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     ap:animation="fade" 
     ap:placementType="interstitial" 
     ap:banner_type="inappad" 
     ap:test_mode="true" 
     ap:canShowMR="false" 
     android:layout_alignParentBottom="true" 
    /> 

</RelativeLayout> 
+0

它的工作原理。但我现在面临新的问题。我编辑了我的问题,如果你想看看。 – rootpanthera

+1

如果他已经解决了你的原始问题,那么答案应该被接受,并开始一个新的问题。如果最初的问题被编辑为新问题,那么对于具有相同问题的其他任何人都没有用。那么答案没有任何意义。与已完成的工作相比,它也破坏了奖励制度。 – Brianjs

+0

@rootpanthera正如Brianjs所说,请另外提问。我会很高兴看到它。 – Szymon