我为项目创建了几个CardView,并注意到它的页面不可滚动,我已经搜索并找到了一些方法,例如将RelativeLayout更改为ScrollView
,但是当我运行我的应用程序时,它崩溃了,它在mainActivity上出现错误java的。因此,我决定改回原先的位置,并将ScrollView
放到LinearLayout
的顶部,但是,我的最后一个CardView并未完全显示出隐藏在底部导航后面的部分。有人可以帮我还是启发我,我应该如何在xml文件中实现ScrollView
?
<RelativeLayout 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:background="@color/white"
android:orientation="vertical"
tools:context=".MainActivity">
<com.google.android.material.bottomnavigation.BottomNavigationView ...>
<LinearLayout
android:id="@+id/frame_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/btm_nav"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar...>
<technolifestyle.com.imageslider.FlipperLayout ...>
<androidx.cardview.widget.CardView ...>
<androidx.cardview.widget.CardView ...>
<androidx.cardview.widget.CardView ...>
</LinearLayout>
</RelativeLayout>
RelativeLayout
放入ScrollView中。此外,如果最后一张卡片在bottomNavigation后面,则将android:clipToPadding="false"
属性添加到ScrollView并添加一些底部填充。