2015-04-08 88 views
0

我想更改admob的位置。我嘗試將我的admob代碼移到​​相對佈局的頂部,但不幸的是,您的應用程序已關閉。那我該怎麼做。謝謝諮詢如何更改admob位置

XML代碼:

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

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:ads="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/content" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:baselineAligned="false" 
    android:orientation="vertical" > 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" > 

     <FrameLayout 
      android:id="@+id/web_view" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_marginBottom="@dimen/card_show_stick_height_without_shadow" /> 

     <ProgressBar 
      android:id="@+id/web_view_progress" 
      style="?android:attr/progressBarStyleHorizontal" 
      android:layout_width="match_parent" 
      android:layout_height="3dp" 
      android:layout_alignParentTop="true" 
      android:background="@drawable/progress_bar_status" 
      android:indeterminateOnly="false" 
      android:max="100" /> 

     <View 
      android:id="@+id/web_view_buttons_divider" 
      android:layout_width="match_parent" 
      android:layout_height="2dp" 
      android:layout_alignParentBottom="true" 
      android:background="@drawable/ad_bottom_sticky_uppershadow" /> 
    </RelativeLayout> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/card_show_stick_height" 
     android:background="@android:color/black" > 

     <ImageButton 
      android:id="@+id/web_view_btn_back" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_alignParentLeft="true" 
      android:background="@android:color/transparent" 
      android:paddingLeft="@dimen/web_view_margin_1" 
      android:paddingRight="@dimen/web_view_margin_2" 
      android:src="@drawable/stick_btn_back" /> 

     <ImageButton 
      android:id="@+id/web_view_btn_forward" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_toRightOf="@id/web_view_btn_back" 
      android:background="@android:color/transparent" 
      android:paddingRight="@dimen/web_view_margin_3" 
      android:src="@drawable/stick_btn_forward" /> 

     <FrameLayout 
      android:id="@+id/web_view_lay_refresh" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_toRightOf="@id/web_view_btn_forward" 
      android:paddingRight="@dimen/web_view_margin_4" > 

      <ImageButton 
       android:id="@+id/web_view_btn_refresh" 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" 
       android:background="@android:color/transparent" 
       android:src="@drawable/stick_btn_refresh" 
       android:visibility="invisible" /> 

      <ProgressBar 
       android:id="@+id/loading" 
       style="?android:attr/progressBarStyleSmallInverse" 
       android:layout_width="@dimen/loading_spinner_size_small" 
       android:layout_height="@dimen/loading_spinner_size_small" 
       android:layout_gravity="center_vertical" 
       android:visibility="visible" /> 
     </FrameLayout> 

     <ImageButton 
      android:id="@+id/web_view_btn_share" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_toRightOf="@id/web_view_lay_refresh" 
      android:background="@android:color/transparent" 
      android:paddingRight="@dimen/web_view_margin_5" 
      android:src="@drawable/stick_btn_share" /> 
    </RelativeLayout> 

    <com.google.android.gms.ads.AdView 
     android:id="@+id/adView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     ads:adSize="SMART_BANNER" 
     ads:adUnitId="ca-app-pub-2128604123953452/6982779835" > 
    </com.google.android.gms.ads.AdView> 

</LinearLayout> 

- 這就是我 - enter image description here

- 這就是我想要的 - enter image description here

+0

對此,您的父級佈局應該是'RelativeLayout'而不是'LinearLayout'。 –

回答

1

嘗試:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:ads="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/content" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:baselineAligned="false" 
    android:orientation="vertical" > 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" > 

     <FrameLayout 
      android:id="@+id/web_view" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_marginBottom="@dimen/card_show_stick_height_without_shadow" /> 

     <ProgressBar 
      android:id="@+id/web_view_progress" 
      style="?android:attr/progressBarStyleHorizontal" 
      android:layout_width="match_parent" 
      android:layout_height="3dp" 
      android:layout_alignParentTop="true" 
      android:background="@drawable/progress_bar_status" 
      android:indeterminateOnly="false" 
      android:max="100" /> 

     <View 
      android:id="@+id/web_view_buttons_divider" 
      android:layout_width="match_parent" 
      android:layout_height="2dp" 
      android:layout_alignParentBottom="true" 
      android:background="@drawable/ad_bottom_sticky_uppershadow" /> 
    </RelativeLayout> 
    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@android:color/black" > 
     <com.google.android.gms.ads.AdView 
      android:id="@+id/adView" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      ads:adSize="SMART_BANNER" 
      ads:adUnitId="ca-app-pub-2128604123953452/6982779835" > 
     </com.google.android.gms.ads.AdView> 

    </RelativeLayout> 
    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/card_show_stick_height" 
     android:background="@android:color/black" > 

     <ImageButton 
      android:id="@+id/web_view_btn_back" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_alignParentLeft="true" 
      android:background="@android:color/transparent" 
      android:paddingLeft="@dimen/web_view_margin_1" 
      android:paddingRight="@dimen/web_view_margin_2" 
      android:src="@drawable/stick_btn_back" /> 

     <ImageButton 
      android:id="@+id/web_view_btn_forward" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_toRightOf="@id/web_view_btn_back" 
      android:background="@android:color/transparent" 
      android:paddingRight="@dimen/web_view_margin_3" 
      android:src="@drawable/stick_btn_forward" /> 

     <FrameLayout 
      android:id="@+id/web_view_lay_refresh" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_toRightOf="@id/web_view_btn_forward" 
      android:paddingRight="@dimen/web_view_margin_4" > 

      <ImageButton 
       android:id="@+id/web_view_btn_refresh" 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" 
       android:background="@android:color/transparent" 
       android:src="@drawable/stick_btn_refresh" 
       android:visibility="invisible" /> 

      <ProgressBar 
       android:id="@+id/loading" 
       style="?android:attr/progressBarStyleSmallInverse" 
       android:layout_width="@dimen/loading_spinner_size_small" 
       android:layout_height="@dimen/loading_spinner_size_small" 
       android:layout_gravity="center_vertical" 
       android:visibility="visible" /> 
     </FrameLayout> 

     <ImageButton 
      android:id="@+id/web_view_btn_share" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_toRightOf="@id/web_view_lay_refresh" 
      android:background="@android:color/transparent" 
      android:paddingRight="@dimen/web_view_margin_5" 
      android:src="@drawable/stick_btn_share" /> 
    </RelativeLayout> 

</LinearLayout> 
+1

它的工作表示感謝! – Dauezevy

+0

@Dauezevy接受我的回答) –