【发布时间】:2014-11-12 06:13:21
【问题描述】:
在LinearLayout中,我的添加无法显示,说没有足够的广告空间,当我将其更改为RelativeLayout时,广告可以显示,但是我保留在顶部的按钮不见了。请帮我。而且,如果可能的话,我想把我的添加放在底部。谢谢。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="25"
android:onClick="gotoPreviousImage"
android:padding="10dip"
android:text="<" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="50"
android:onClick="setAsWallpaper"
android:padding="10dip"
android:text="Set as Background" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="25"
android:onClick="gotoNextImage"
android:padding="10dip"
android:text=">" />
</LinearLayout>
<ImageView
android:id="@+id/backgroundPreview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:contentDescription="Preview of the wallpaper to choose"
android:scaleType="fitXY" />
<com.google.android.gms.ads.AdView
android:id="@+id/AdView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adUnitId="Unit_ID"
ads:adSize="SMART_BANNER"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
/>
</LinearLayout>
【问题讨论】:
-
尝试为单个子组件赋予像 layout_weight 这样的权重
-
你是如何显示这个 ImageView 的?我猜这个有 fill_parent 的高度和宽度。因此,请尝试将其删除一会儿,看看其他一切是否正常。
-
@vo12 不工作 :( 仍然是同样的错误“没有足够的空间来展示广告。需要 360x50 dp,但只有 360x0 dp。”
-
伙计,你已经在第一个子线性布局、imageview 和 adview 上放置了垂直方向放置权重,并使高度为 0px
-
@SeijiDinzuala 给 Imageview 高度 wrap_parent
标签: android xml android-layout android-studio