我已經得到了這個項目,並且我把它放在了admob上,但廣告必須始終位於屏幕的底部,當您在頁面上下滾動時,廣告必須保持在同一個地方。不能從滾動視圖中移除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>
當你說「廣告有自己的小滾動視圖佈局」,你能解釋一下,或提供問題的截圖? – Kirk
theres上面的截圖,如果你看看它的廣告部分,它有一條小線顯示它使用滾動視圖佈局的事情 – James
啊,我明白了。您可以發佈您如何製作廣告的代碼? – Kirk