首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >安卓GridView和下面的广告

安卓GridView和下面的广告
EN

Stack Overflow用户
提问于 2011-01-14 15:45:02
回答 1查看 2.9K关注 0票数 1

我正在尝试将广告(admob)集成到我的Android应用程序中。除了布局上的一个问题之外,它基本上是正常工作的。我的布局包括:

代码语言:javascript
运行
复制
<?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>  

广告显示在屏幕的底部,正如我所希望的那样。但是,它们似乎被覆盖或绘制在网格视图的底部。我希望网格视图更短,这样广告就可以填满屏幕的底部,而不是隐藏网格视图的一部分。问题是当你一直滚动到网格视图的底部时,由于广告的原因,你仍然不能完全看到网格中的最后一行项目。

我不确定这是否是AdMob广告的标准工作方式。如果是这样的话,在网格的底部添加一些填充(如果可能的话)就可以解决这个问题了。这样,用户可以再滚动一点,除了广告之外,还可以看到最后一行。

在读到一些与ListViews类似的问题后,我从使用LinearLayout转到了RelativeLayout。现在我的广告是沿着底部而不是网格上方,所以我越来越近了。

想法?-Kevin

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-01-14 15:48:02

将此属性放入您的网格视图

代码语言:javascript
运行
复制
android:layout_above="@+id/ad"
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4688936

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档