2016-11-24 184 views
1

移動廣告上的佈局頂端的廣告不會被放置在頂部佈局,像廣告放置在底部。它不是重疊佈局。發生在安卓

這裏是佈局的形象,我在說一下,看看 Image of the layout

這裏是它

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:ads="http://schemas.android.com/apk/res-auto" 
    tools:context="com.dancing.dance.girl" 
    android:background="@mipmap/vsdv"> 


    <com.google.android.gms.ads.AdView 
     android:id="@+id/abovebeauty" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_alignParentTop="true" 
     ads:adSize="BANNER" 
     ads:adUnitId="@string/dancinggirl"> 
    </com.google.android.gms.ads.AdView> 



    <!-- TODO: Update blank fragment layout --> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 

     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:weightSum="2" 
     android:id="@+id/beauty_fragment" 
     android:orientation="vertical" 
     android:padding="10dp"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      android:orientation="horizontal" 
      android:weightSum="2" > 

      <ImageButton 
       android:layout_width="0dp" 
       android:layout_height="fill_parent" 
       android:id="@+id/1" 
       android:layout_weight="1" 
       android:src="@drawable/lob" 
       android:background="@null" 
       android:scaleType="fitXY" 


       android:layout_marginLeft="20dp" 
       android:layout_marginRight="5dp" 
       android:layout_marginTop="20dp" 
       android:layout_marginBottom="5dp" /> 
      <ImageButton 
       android:layout_width="0dp" 
       android:layout_height="fill_parent" 
       android:id="@+id/2" 
       android:layout_weight="1" 
       android:src="@drawable/lob" 
       android:background="@null" 
       android:scaleType="fitXY" 


       android:layout_marginTop="20dp" 
       android:layout_marginLeft="5dp" 
       android:layout_marginRight="20dp" 
       android:layout_marginBottom="5dp" /> 




     </LinearLayout> 


     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      android:orientation="horizontal" 
      android:weightSum="2" > 

      <ImageButton 
       android:layout_width="0dp" 
       android:layout_height="fill_parent" 
       android:layout_weight="1" 
       android:src="@drawable/lob" 
       android:background="@null" 
       android:scaleType="fitXY" 
       android:id="@+id/3" 

       android:layout_marginLeft="20dp" 
       android:layout_marginRight="5dp" 
       android:layout_marginBottom="20dp" 
       android:layout_marginTop="5dp" /> 



      <ImageButton 
       android:layout_width="0dp" 
       android:layout_height="fill_parent" 
       android:layout_weight="1" 
       android:src="@drawable/lob" 
       android:background="@null" 
       android:scaleType="fitXY" 
       android:id="@+id/4" 

       android:layout_marginTop="5dp" 
       android:layout_marginRight="20dp" 
       android:layout_marginLeft="5dp" 
       android:layout_marginBottom="20dp" /> 
     </LinearLayout> 

    </LinearLayout> 
    <com.google.android.gms.ads.AdView 
     android:id="@+id/beautyfragment" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_alignParentBottom="true" 
     ads:adSize="BANNER" 
     ads:adUnitId="@string/dancinggirl"> 
    </com.google.android.gms.ads.AdView> 
</RelativeLayout> 

三江源的XML代碼的看着它。

+0

加上'機器人:layout_below = 「abovebeauty」'在'beauty_fragment'的LinearLayout –

+0

使用frameLayout – SaravInfern

+0

@Ankur你見過嗎? e圖像?,我需要它重疊,就像在圖像中放置在屏幕底部的廣告一樣。 – Sarthakpandit

回答

0

嘗試這種方式下面的LinearLayout

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
xmlns:ads="http://schemas.android.com/apk/res-auto" 
tools:context="com.dancing.dance.girl" 
android:background="@mipmap/vsdv"> 






<!-- TODO: Update blank fragment layout --> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 

    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:weightSum="2" 
    android:id="@+id/beauty_fragment" 
    android:orientation="vertical" 
    android:padding="10dp"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:orientation="horizontal" 
     android:weightSum="2" > 

     <ImageButton 
      android:layout_width="0dp" 
      android:layout_height="fill_parent" 
      android:id="@+id/1" 
      android:layout_weight="1" 
      android:src="@drawable/lob" 
      android:background="@null" 
      android:scaleType="fitXY" 


      android:layout_marginLeft="20dp" 
      android:layout_marginRight="5dp" 
      android:layout_marginTop="20dp" 
      android:layout_marginBottom="5dp" /> 
     <ImageButton 
      android:layout_width="0dp" 
      android:layout_height="fill_parent" 
      android:id="@+id/2" 
      android:layout_weight="1" 
      android:src="@drawable/lob" 
      android:background="@null" 
      android:scaleType="fitXY" 


      android:layout_marginTop="20dp" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="20dp" 
      android:layout_marginBottom="5dp" /> 




    </LinearLayout> 


    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:orientation="horizontal" 
     android:weightSum="2" > 

     <ImageButton 
      android:layout_width="0dp" 
      android:layout_height="fill_parent" 
      android:layout_weight="1" 
      android:src="@drawable/lob" 
      android:background="@null" 
      android:scaleType="fitXY" 
      android:id="@+id/3" 

      android:layout_marginLeft="20dp" 
      android:layout_marginRight="5dp" 
      android:layout_marginBottom="20dp" 
      android:layout_marginTop="5dp" /> 



     <ImageButton 
      android:layout_width="0dp" 
      android:layout_height="fill_parent" 
      android:layout_weight="1" 
      android:src="@drawable/lob" 
      android:background="@null" 
      android:scaleType="fitXY" 
      android:id="@+id/4" 

      android:layout_marginTop="5dp" 
      android:layout_marginRight="20dp" 
      android:layout_marginLeft="5dp" 
      android:layout_marginBottom="20dp" /> 
    </LinearLayout> 

</LinearLayout> 

<com.google.android.gms.ads.AdView 
    android:id="@+id/abovebeauty" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_alignParentTop="true" 
    ads:adSize="BANNER" 
    ads:adUnitId="@string/dancinggirl"> 
</com.google.android.gms.ads.AdView> 

<com.google.android.gms.ads.AdView 
    android:id="@+id/beautyfragment" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_alignParentBottom="true" 
    ads:adSize="BANNER" 
    ads:adUnitId="@string/dancinggirl"> 
</com.google.android.gms.ads.AdView> 

+0

謝謝你的工作。 – Sarthakpandit

+0

如果有幫助,請接受答案:) – Redman

1

認沽廣告佈局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
xmlns:ads="http://schemas.android.com/apk/res-auto" 
tools:context="com.dancing.dance.girl" 
android:background="@mipmap/vsdv"> 


<!-- TODO: Update blank fragment layout --> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 

    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:weightSum="2" 
    android:id="@+id/beauty_fragment" 
    android:orientation="vertical" 
    android:padding="10dp"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:orientation="horizontal" 
     android:weightSum="2" > 

     <ImageButton 
      android:layout_width="0dp" 
      android:layout_height="fill_parent" 
      android:id="@+id/1" 
      android:layout_weight="1" 
      android:src="@drawable/lob" 
      android:background="@null" 
      android:scaleType="fitXY" 


      android:layout_marginLeft="20dp" 
      android:layout_marginRight="5dp" 
      android:layout_marginTop="20dp" 
      android:layout_marginBottom="5dp" /> 
     <ImageButton 
      android:layout_width="0dp" 
      android:layout_height="fill_parent" 
      android:id="@+id/2" 
      android:layout_weight="1" 
      android:src="@drawable/lob" 
      android:background="@null" 
      android:scaleType="fitXY" 


      android:layout_marginTop="20dp" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="20dp" 
      android:layout_marginBottom="5dp" /> 




    </LinearLayout> 


    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:orientation="horizontal" 
     android:weightSum="2" > 

     <ImageButton 
      android:layout_width="0dp" 
      android:layout_height="fill_parent" 
      android:layout_weight="1" 
      android:src="@drawable/lob" 
      android:background="@null" 
      android:scaleType="fitXY" 
      android:id="@+id/3" 

      android:layout_marginLeft="20dp" 
      android:layout_marginRight="5dp" 
      android:layout_marginBottom="20dp" 
      android:layout_marginTop="5dp" /> 



     <ImageButton 
      android:layout_width="0dp" 
      android:layout_height="fill_parent" 
      android:layout_weight="1" 
      android:src="@drawable/lob" 
      android:background="@null" 
      android:scaleType="fitXY" 
      android:id="@+id/4" 

      android:layout_marginTop="5dp" 
      android:layout_marginRight="20dp" 
      android:layout_marginLeft="5dp" 
      android:layout_marginBottom="20dp" /> 
    </LinearLayout> 

</LinearLayout> 
<com.google.android.gms.ads.AdView 
    android:id="@+id/beautyfragment" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_alignParentBottom="true" 
    ads:adSize="BANNER" 
    ads:adUnitId="@string/dancinggirl"> 
</com.google.android.gms.ads.AdView> 


<com.google.android.gms.ads.AdView 
    android:id="@+id/abovebeauty" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_alignParentTop="true" 
    ads:adSize="BANNER" 
    ads:adUnitId="@string/dancinggirl"> 
</com.google.android.gms.ads.AdView> 

+0

您發佈了和我一樣的答案-_- – Redman

+0

那麼,這是正確的解決方案,我也寫在同一時間 –

+0

謝謝你的工作。 – Sarthakpandit