我的MainActivity.xml中有一整頁ScrollView線性佈局。現在我想在ScrollView佈局後添加Admob Banner Ad佈局,這樣我的旗幟就會保持粘性。但在ScrollView佈局之後,無論我做什麼添加,都不顯示任何內容。如果我在ScrollView中廣告橫幅廣告代碼,它可以工作,但我需要將它放在滾動視圖佈局之後。我想要ScrollView layout_height =「wrap_content」,因爲設備到設備的高度/寬度有所不同。需要某人的幫助。我的XML代碼如下:ScrollView線性佈局未顯示後的佈局內容
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/back2"
tools:context="com.domain.appname.MainActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="230dp"
app:srcCompat="@drawable/head" />
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="App Title"
android:textAlignment="center"
android:textSize="24sp"
android:textStyle="bold"
android:layout_marginTop="15dp" />
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="20dp"
android:text="App Description"
android:textSize="20sp"/>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="15dp"
android:text="List Page"
android:layout_marginBottom="15dp"
android:textSize="20sp"
style="@style/Widget.AppCompat.Button.Colored"
android:onClick="switcher"/>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="@string/banner_ad_unit_id"
>
</com.google.android.gms.ads.AdView>
</LinearLayout>
</LinearLayout>
Thanks @RobCo,它完美的作品:) –