【发布时间】:2011-01-14 07:45:01
【问题描述】:
我正在尝试将广告 (admob) 集成到我的 Android 应用中。它大部分都在工作,除了布局有一个问题。我的布局包括:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:app="http://schemas.android.com/apk/res/com.example.photos">
<LinearLayout android:orientation="horizontal"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="@+id/status_layout">
<ImageView android:id="@+id/cardStatus"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/hello"
android:id="@+id/cardStatusText" />
</LinearLayout>
<GridView android:id="@+id/imageGridView"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:padding="10dp" android:verticalSpacing="10dp"
android:horizontalSpacing="10dp" android:numColumns="auto_fit"
android:columnWidth="100dp" android:stretchMode="columnWidth"
android:gravity="center" android:layout_below="@id/status_layout" />
<!-- Place an AdMob ad at the bottom of the screen. -->
<!-- It has white text on a black background. -->
<!-- The description of the surrounding context is 'Android game'. -->
<com.admob.android.ads.AdView android:id="@+id/ad"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_alignParentBottom="true" app:backgroundColor="#000000"
app:primaryTextColor="#FFFFFF" app:secondaryTextColor="#CCCCCC"
app:keywords="Android Photo" />
</RelativeLayout>
广告显示在屏幕底部,正如我所愿。但是,它们似乎被覆盖或绘制在网格视图底部的顶部。我希望 gridview 更短,以便广告可以填充屏幕的底部,而不是隐藏部分 gridview。当您一直滚动到网格视图的底部时,这个问题最烦人,并且由于广告,您仍然无法完全看到网格中的最后一行项目。
我不确定这是否是 AdMob 广告的标准运作方式。如果是这种情况,在网格底部添加一些填充(如果可能的话)将是技巧。这样用户就可以再滚动一点,看到除了广告之外的最后一行。
在阅读了 ListViews 的一些类似问题后,我刚刚从使用 LinearLayout 切换到 RelativeLayout。现在我的广告是在底部而不是在网格上方,所以我越来越近了。
想法? -凯文
【问题讨论】:
标签: android android-widget android-layout