[英]How to fix that layout in android
Android和Java上的新功能。
一个简单的问题在这里为您服务。
我的申请非常简单。 我有向用户显示的图像库。 当他单击图像时,正在加载一个新图像。 我在底部有一个admob。
但是我无法根据需要放置它们。 此刻的广告没有显示,并且返回错误,提示宽度没有足够的空间。 我想使图像从屏幕的一端到另一端。 目前,图像的每一面都带有黑色大边框。
这是我的活动:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" xmlns:app="http://schemas.android.com/apk/lib/com.google.ads">
<com.loopj.android.image.SmartImageView
android:id="@+id/image_switcher"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
app:adSize="SMART_BANNER"
app:adUnitId="738a44d913034b9f" >
</com.google.ads.AdView>
将SmartImageView更改为0dp的高度和layout_weight =“ 1”。 该视图将占据所有可用的位置,并让广告请求自己的高度。
您已将SmartImageView
的高度设置为match_parent
,为AdView
留出了空间
<com.loopj.android.image.SmartImageView
android:id="@+id/image_switcher"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
如果您希望ImageView占用广告上的所有可用空间,请使用以下代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" xmlns:app="http://schemas.android.com/apk/lib/com.google.ads">
<com.loopj.android.image.SmartImageView
android:id="@+id/image_switcher"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/ad" />
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:adSize="SMART_BANNER"
app:adUnitId="738a44d913034b9f" >
</com.google.ads.AdView>
</RelativeLayout
这样,您的ImageView将始终位于广告上方。
如果要使用Stephane的解决方案,则需要将RelativeLayout更改为LinearLayout。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.