如何使我的RelativeLayout可滚动?

时间:2019-09-29 18:30:22

标签: android xml scrollview android-relativelayout

我为项目创建了几个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>

3 个答案:

答案 0 :(得分:1)

在其中使用Spring documentation,并使其与父项匹配。

答案 1 :(得分:1)

使ScrollView和RelativeLayout的RelativeLayout子级成为match_parent。还要为ScrollView设置fillviewport = true

答案 2 :(得分:1)

RelativeLayout放在ScrollView中。此外,如果最后一张卡片在bottomNavigation的后面,请向ScrollView添加android:clipToPadding="false"属性,并添加一些底部填充。