【发布时间】:2018-01-17 00:28:02
【问题描述】:
我有一个来自 admob 的广告的相对布局。一切正常。但是我让我的用户购买广告(通过应用内购买删除广告)。但是,当 Ad ist 以编程方式删除(将其设置为不可见)时,设计“崩溃”。所有元素都堆叠在屏幕的顶部。在广告中有一个参数:
android:layout_alignParentBottom="true"
这似乎是移除后这种奇怪行为的原因。
如何修复我的布局?
<RelativeLayout 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:id="@+id/game_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_activity"
android:orientation="vertical" >
<RelativeLayout>
</RelativeLayout>
<ImageView>
<LinearLayout
</LinearLayout>
<LinearLayout
</LinearLayout>
</LinearLayout>
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
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>
【问题讨论】:
-
使用可见性:消失。可见性不可见只是隐藏视图但占用布局空间
-
嗨,我已经在使用正确的代码 mAdView.setVisibility(View.GONE);它不是代码问题,我需要一个布局提示,为什么缺少“android:layout_alignParentBottom="true"" 会导致页面崩溃...
标签: android android-layout admob android-relativelayout