2014-04-18 4 views
0

컨테이너에 단편을 삽입하여 모든 화면 하단에 adview를 배치하려고합니다. adview가 LinearLayout을 사용하여 액션 바 아래의 상단에 위치하게 할 수 있습니다. RelativeLayout의 다양한 조합을 시도했지만 아무도 크기 조정 - 방향 adview 스틱을 만드는 것. 안드로이드, 화면 맨 아래에 요소 배치하기

다음은 위로 정상 작동 레이아웃입니다 :

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

    <com.google.android.gms.ads.AdView android:id="@+id/adView" 
             android:layout_width="wrap_content" 
             android:layout_height="wrap_content" 
             ads:adSize="SMART_BANNER"/> 
</LinearLayout> 

그리고 fragmentContainer에 조각을 추가 할 수 있습니다. 광고 뷰를 화면 하단에 정적으로 배치하려면 어떻게해야합니까? 다양한 레이아웃 중첩 전략을 시도했지만 지금까지 아무도 시도하지 못했습니다.

배너는 조각의 일부를 오버레이하거나 잘라서는 안됩니다.

답변

3

alignParentBottom 속성의 RelativeLayout은 어떨까요? 또한 FrameLayout이 아닌 다른보기 그룹 내에 조각을 추가하는 것은 좋지 않습니다. 이것은 활동을 멈추거나 깰 수는 없지만 몇 가지 버그를 제공 할 수 있습니다. 이 같은 트릭을해야합니다 :

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

    <com.google.android.gms.ads.AdView 
     android:layout_alignParentBottom="true" 
     android:id="@+id/adView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     ads:adSize="SMART_BANNER" /> 

    <FrameLayout 
     android:id="@+id/fragmentContainer" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_above="@id/adView" /> 

</RelativeLayout> 

희망이 도움이됩니다.

+0

이렇게하면 배너가 뷰를 오버레이하고 조각에있는 내용의 맨 아래가 잘립니다. –

+0

@StefanKendall 필요에 따라 답변을 업데이트했습니다. 일반적으로 조각은 'layout_above' 속성을 사용하여 adView 위에 유지됩니다. 이것이 당신이 예상 한 것이라면 알려주십시오. – Fllo

+0

그것을 시도해 보겠습니다. –

관련 문제