【发布时间】:2022-10-06 00:54:38
【问题描述】:
我试图将 ScrollView 限制在屏幕的某个部分,因为我试图将横幅广告附加到屏幕底部,并且我希望横幅广告是静态的,而其余内容可以滚动因此我不希望横幅广告受到 ScrollView 的影响。出于某种原因,虽然当我运行我的应用程序时,我的设备屏幕上只有可滚动部分可见,但我的横幅广告根本没有出现。我已经尝试了多种方法来解决此问题以使其正常工作,但我仍然无法弄清楚。 这是我当前的 activity_main.xml 代码
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<androidx.constraintlayout.widget.ConstraintLayout
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\"
android:layout_width=\"match_parent\"
android:layout_height=\"match_parent\"
android:orientation=\"vertical\"
android:background=\"@color/grey\"
tools:context=\".MainActivity\">
<ScrollView
android:layout_width=\"match_parent\"
android:layout_height=\"wrap_content\"
app:layout_constraintEnd_toEndOf=\"parent\"
app:layout_constraintStart_toStartOf=\"parent\"
app:layout_constraintLeft_toLeftOf=\"parent\"
app:layout_constraintRight_toRightOf=\"parent\"
app:layout_constraintTop_toTopOf=\"parent\">
<LinearLayout
android:orientation=\"vertical\"
android:layout_width=\"match_parent\"
android:layout_height=\"wrap_content\">
<androidx.cardview.widget.CardView
android:layout_margin=\"16dp\"
app:cardCornerRadius=\"8dp\"
app:cardElevation=\"8dp\"
app:cardBackgroundColor=\"@color/blue\"
android:layout_width=\"match_parent\"
android:layout_height=\"wrap_content\">
<androidx.appcompat.widget.SearchView
android:id=\"@+id/search_view\"
app:defaultQueryHint=\"Search...\"
app:iconifiedByDefault=\"false\"
android:layout_width=\"match_parent\"
android:layout_height=\"?attr/actionBarSize\"/>
</androidx.cardview.widget.CardView>
<LinearLayout
android:layout_margin=\"16dp\"
android:orientation=\"vertical\"
android:layout_width=\"match_parent\"
android:layout_height=\"match_parent\">
<TextView
android:id=\"@+id/textView_a\"
android:textSize=\"24sp\"
android:text=\"A\"
android:textColor=\"@color/blue\"
android:textAlignment=\"center\"
android:padding=\"8dp\"
android:textStyle=\"italic\"
android:layout_width=\"match_parent\"
android:layout_height=\"wrap_content\"/>
<androidx.recyclerview.widget.RecyclerView
android:id=\"@+id/recycler_phonetics\"
android:layout_width=\"match_parent\"
android:layout_height=\"wrap_content\"/>
<TextView
android:textSize=\"24sp\"
android:text=\"B\"
android:textColor=\"@color/blue\"
android:textAlignment=\"center\"
android:padding=\"8dp\"
android:textStyle=\"italic\"
android:layout_width=\"match_parent\"
android:layout_height=\"wrap_content\"/>
<androidx.recyclerview.widget.RecyclerView
android:id=\"@+id/recycler_meanings\"
android:layout_width=\"match_parent\"
android:layout_height=\"wrap_content\" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width=\"match_parent\"
android:layout_height=\"wrap_content\"
app:layout_constraintBottom_toBottomOf=\"parent\">
<com.google.android.gms.ads.AdView xmlns:ads=\"http://schemas.android.com/apk/res-auto\"
android:id=\"@+id/adView\"
android:layout_width=\"match_parent\"
android:layout_height=\"wrap_content\"
ads:adSize=\"BANNER\"
ads:adUnitId=\"ca-app-pub-3940256099942544/6300978111\"
app:layout_constraintBottom_toBottomOf=\"parent\"
app:layout_constraintEnd_toEndOf=\"parent\"
app:layout_constraintStart_toStartOf=\"parent\">
</com.google.android.gms.ads.AdView>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
标签: java android xml android-studio android-11