如何使我的RelativeLayout可滚动?

问题描述 投票:-1回答:3

我为项目创建了几个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>
android xml scrollview android-relativelayout
3个回答
0
投票
在其中使用ScrollView,并使其与父项匹配。

0
投票
将ScrollView和RelativeLayout的RelativeLayout子级设为match_parent。同时为ScrollView设置fillviewport = true

0
投票
RelativeLayout放入ScrollView中。此外,如果最后一张卡片在bottomNavigation后面,则将android:clipToPadding="false"属性添加到ScrollView并添加一些底部填充。
© www.soinside.com 2019 - 2024. All rights reserved.