我有这个项目,我把 admob 放在上面,但广告必须始终位于屏幕底部,当您上下滚动页面时,广告必须保持在同一个位置。
由于广告有自己的小滚动视图布局,似乎我在某处做错了什么?我在下面放了一个屏幕截图以及布局的代码
编辑了 homexml 代码但有错误
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:id="@+id/ScrlView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="20dp"
android:layout_weight="1">
<ScrollView
android:id="@+id/ScrlView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/MainActivity"
android:layout_marginBottom="20dp" >
<LinearLayout
android:id="@+id/layoutForScroll"
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="vertical" >
<TextView
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="23dp"
android:gravity="center"
android:text="Welcome To Ride Count!"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#1E90FF"
android:textStyle="bold" >
</TextView>
<RelativeLayout
android:id="@+id/layoutTextViews_one"
android:layout_width="280dp"
android:layout_height="100dp"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:background="@drawable/smallbox1" >
<TextView
android:id="@+id/txtCountLabel_one"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="24dp"
android:gravity="center"
android:text="Rides Ridden:"
android:textColor="#1E90FF"
android:textStyle="bold" >
</TextView>
<TextView android:textStyle="bold" android:gravity="center" android:text="0000" android:layout_height="wrap_content"
android:layout_width="match_parent" android:id="@+id/sum"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000" android:layout_marginTop="45dp"></TextView>
</RelativeLayout>
<TextView
android:id="@+id/txtFact"
android:layout_width="280dp"
android:layout_height="180dp"
android:layout_gravity="center"
android:layout_marginTop="23dp"
android:background="@drawable/factbox"
android:gravity="center"
android:text="Tap For Fact"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000"
android:textStyle="bold" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="@+id/MainActivity"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="0dp"
android:layout_weight="2">
</LinearLayout>
<com.google.ads.AdView
xmlns:googleads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/ad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
googleads:adSize="SMART_BANNER"
googleads:adUnitId="@string/admob_id" />
</LinearLayout>
广告暴民布局代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ad_catalog_layout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/banner_bottom" />
<TextView android:id="@+id/status"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
android:text="" />
<com.google.ads.AdView
xmlns:googleads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/ad"
android:layout_width="fill_parent"
android:layout_height="60dp"
googleads:adSize="IAB_MRECT"
googleads:adUnitId="@string/admob_id" />
</LinearLayout>
主页 XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/backgroundtowers"
android:orientation="vertical"
android:scrollbars="vertical"
android:weightSum="1" >
<ScrollView
android:id="@+id/ScrlView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/MainActivity"
android:layout_marginBottom="20dp" >
<LinearLayout
android:id="@+id/layoutForScroll"
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="vertical" >
<TextView
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="23dp"
android:gravity="center"
android:text="Welcome To Ride Count"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#1E90FF"
android:textStyle="bold" >
</TextView>
<RelativeLayout
android:id="@+id/layoutTextViews_one"
android:layout_width="280dp"
android:layout_height="100dp"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:background="@drawable/smallbox1" >
<TextView
android:id="@+id/txtCountLabel_one"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="24dp"
android:gravity="center"
android:text="Rides Ridden:"
android:textColor="#1E90FF"
android:textStyle="bold" >
</TextView>
<TextView
android:id="@+id/sum"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="45dp"
android:gravity="center"
android:text="0000"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000"
android:textStyle="bold" >
</TextView>
</RelativeLayout>
<TextView
android:id="@+id/txtFact"
android:layout_width="280dp"
android:layout_height="180dp"
android:layout_gravity="center"
android:layout_marginTop="23dp"
android:background="@drawable/factbox"
android:gravity="center"
android:text="Tap For Fact"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000"
android:textStyle="bold" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="@+id/MainActivity"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_marginTop="0dp" >
</LinearLayout>
</RelativeLayout>