-1

I created few CardView for my project and notice it that my page is not scrollable, I've search and found some method like changing the RelativeLayout to ScrollView but when i run my apps it crash it got an error on my mainActivity java. So I decided to change it back and put the ScrollView on the top of my LinearLayout it works but, my last CardView didn't fully show up some the part got hidden behind the bottom navigation. Can someone help me or enlighten me how should i implement the ScrollView inside my xml file?

<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>
Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
lilin
  • 117
  • 1
  • 2
  • 10

3 Answers3

1

Use ScrollView inside it, and make it match parent.

1

Make RelativeLayout child of ScrollView and RelativeLayout to match_parent. Also set fillviewport = true for ScrollView

Hamza Khan
  • 1,433
  • 13
  • 19
1

Put your RelativeLayout inside a ScrollView. Furthermore, if your last cards are behind the bottomNavigation add android:clipToPadding="false" attribute to ScrollView and add some bottom padding.

ViduraPrasangana
  • 858
  • 9
  • 17