2017-03-07 1 views
0

내 AdView는 RelativeLayout의 맨 아래에 배치되지만 내 RelativeLayout은 화면을 벗어나서 내 AdView를 볼 수 없게 만듭니다. 어떻게 수정해야합니까?화면에서 벗어나는 RelativeLayout 내부의 AdView

편집 :이 XML에는 축소 된 툴바 레이아웃이 포함되어 있습니다.

XML :

<?xml version="1.0" encoding="utf-8"?> 
    <android.support.design.widget.CoordinatorLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    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:fitsSystemWindows="true"> 

    <android.support.design.widget.AppBarLayout 
    ... 
    </android.support.design.widget.AppBarLayout> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:paddingLeft="@dimen/activity_horizontal_margin" 
     android:paddingRight="@dimen/activity_horizontal_margin" 
     android:paddingTop="@dimen/activity_vertical_margin" 
     android:paddingBottom="@dimen/activity_vertical_margin" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

     <android.support.v4.widget.SwipeRefreshLayout 
      android:id="@+id/category_swipe_refresh_layout" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <android.support.v7.widget.RecyclerView 
       android:id="@+id/recyclerview_category_details" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:scrollbars="vertical"/> 

     </android.support.v4.widget.SwipeRefreshLayout> 

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

    </RelativeLayout> 

</android.support.design.widget.CoordinatorLayout> 
+0

XML 파일을 게시 할 수 있습니까? –

+0

@AngeloParente 추가됨 – RandomyzeEverything

+0

답변을 추가했습니다. 도움이되는지 확인하십시오. 코드 예제입니다. –

답변

0

또 다른 RelativeLayout 및 설정 속성 android:above="@id/adview"에서 둘 다 넣어.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     xmlns:ads="http://schemas.android.com/apk/res-auto" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     tools:context=".MainActivity"> 

     <android.support.design.widget.CoordinatorLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:app="http://schemas.android.com/apk/res-auto" 
      android:id="@+id/main_content" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_above="@+id/adView"> 

      <android.support.design.widget.AppBarLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:background="@drawable/main_button_background"> 

      </android.support.design.widget.AppBarLayout> 

      <android.support.v4.widget.SwipeRefreshLayout 
       android:id="@+id/category_swipe_refresh_layout" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 

       <android.support.v7.widget.RecyclerView 
        android:id="@+id/recyclerview_category_details" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:scrollbars="vertical"/> 

      </android.support.v4.widget.SwipeRefreshLayout> 

     </android.support.design.widget.CoordinatorLayout> 

     <com.google.android.gms.ads.AdView 
      android:id="@id/adView" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      ads:adSize="BANNER" 
      ads:adUnitId="@string/banner_ad_unit_id" 
      android:layout_gravity="center|bottom" 
      android:layout_alignParentBottom="true"/> 

    </RelativeLayout> 

이 도움이된다면 알려주세요 :

당신은, 부모 레이아웃으로 RelativeLayout를 사용하는 그것의 하단에있는로 AdView를 넣어 android:layout_above="@+id/adView" 속성을 지정해야한다,이 샘플 코드입니다.

+0

감사. 그게 효과가 있었어! – RandomyzeEverything

+0

당신은 환영합니다 :) –

0

레이아웃에서 adview을 삭제하고 그런 일을 시도 내부 RelativeLayout

+0

그건 작동하지 않습니다. 지금 내 XML을 게시물에 추가했습니다. – RandomyzeEverything

관련 문제