gpt4 book ai didi

android - Android ListView 上的 Admob 横幅调整

转载 作者:行者123 更新时间:2023-11-29 17:50:20 35 4
gpt4 key购买 nike

我有 ListView ,我想在这个 ListView 的底部显示广告横幅,而且我已经为这个横幅创建了空间,即 android:paddingBottom="50dp",所以我想在这个 50dp 的空间上显示广告,但是现在我的广告显示在这个 50dp 空间的上方,我有 1 个 MainActivity.java 和 2 个 xml 文件,第一个是 activity_main.xml,第二个是 single_row.xml。我们知道不需要显示 java 类,因为我们通过 xml 设置广告调整。所以我在这里分享我的两个 xml,并记住我的相对布局不是线性的,所以没有 layout_weight 选项。activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg"
android:paddingBottom="50dp"
tools:context=".MainActivity" >

<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
</ListView>

<LinearLayout
android:id="@+id/layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true" >

<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
ads:adSize="BANNER"
ads:adUnitId="aaaa111122223333"
ads:loadAdOnCreate="true"
ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" >
</com.google.ads.AdView>
</LinearLayout>
</RelativeLayout>

我的 sigle_row.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_margin="10dp"
android:src="@drawable/img0"
android:paddingBottom="10dp" />

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignTop="@+id/imageView1"
android:layout_toLeftOf="@+id/imageView1"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFFF00"
android:textStyle="bold"
/>
</RelativeLayout>

最佳答案

您需要为 ListView 设置 layout_above 以放置在 AdView 布局上方,以便您可以看到所有列表项

 android:layout_above="@+id/layout"

此外,从父 RelativeLayout 中移除底部的 padding

关于android - Android ListView 上的 Admob 横幅调整,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23357198/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com