Я переключаюсь через Fragments
из моего основного вида деятельности. На данный момент я звоню в новый AdView
с каждого Fragment
, но я хочу только позвонить одному AdView
из основной деятельности, которая отображается на всех Fragments
.Adview Below FrameLayout
Теперь мне просто нужно знать, как получить AdView
, чтобы не показывать внутри FrameLayout
, потому что теперь он блокирует контент внизу.
Так как я могу получить AdView
снаружи/ниже содержания в FrameLayout
?
content_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".activity.MainActivity"
tools:showIn="@layout/app_bar_main">
<FrameLayout
android:id="@+id/mainFrame"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/mainFrame">
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_gravity="center"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>
</RelativeLayout>
</RelativeLayout>
Измените свой верхний '' RelativeLayout' к LinearLayout', а затем добавить 'андроида: layout_weight = "1"' на вспомогательном 'RelativeLayout'. – doubotis
Проверьте мой ответ ниже и дайте мне знать, если у вас возникнут какие-либо проблемы. –