I created a layout using widget CardView. its displaying the card view list but not scrolling down please see my layout bellow. i also created AppWall.java. do need to add any thing to java class or layout to make it work.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:gravity="center_horizontal"
android:orientation="vertical"
tools:context="net.example.app.AppWall">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ddd"
android:orientation="vertical"
android:padding="16dp">
<Space
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbar"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:minHeight="55dp"
android:id="@+id/topspace">
</Space>
<android.support.v7.widget.CardView
android:id="@+id/android_card_view_example"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:elevation="4dp"
android:padding="16dp">
<ImageView
android:id="@+id/cardview_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginRight="18dp"
android:src="@drawable/profile" />
<TextView
android:id="@+id/cardview_list_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/cardview_image"
android:paddingBottom="5dp"
android:text="Flipkart App"
android:textSize="24sp" />
<TextView
android:id="@+id/tvInstall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/cardview_list_title"
android:layout_toRightOf="@+id/cardview_image"
android:text="Install"
android:textColor="@android:color/holo_green_dark"
android:textSize="16sp" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/android_card_view_example1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:elevation="4dp"
android:padding="16dp">
<ImageView
android:id="@+id/cardview_image1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginRight="18dp"
android:src="@drawable/profile" />
<TextView
android:id="@+id/cardview_list_title1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/cardview_image1"
android:paddingBottom="5dp"
android:text="Viral Android"
android:textSize="24sp" />
<TextView
android:id="@+id/short_description1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/cardview_list_title1"
android:layout_toRightOf="@+id/cardview_image1"
android:text="Free android tutorials and examples for beginners and expert."
android:textColor="#8b8b8b" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/android_card_view_example2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:elevation="4dp"
android:padding="16dp">
<ImageView
android:id="@+id/cardview_image2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginRight="18dp"
android:src="@drawable/profile" />
<TextView
android:id="@+id/cardview_list_title2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/cardview_image2"
android:paddingBottom="5dp"
android:text="Viral Android"
android:textSize="24sp" />
<TextView
android:id="@+id/short_description2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/cardview_list_title2"
android:layout_toRightOf="@+id/cardview_image2"
android:text="Free android tutorials and examples for beginners and expert."
android:textColor="#8b8b8b" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/android_card_view_example3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:elevation="4dp"
android:padding="16dp">
<ImageView
android:id="@+id/cardview_image3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginRight="18dp"
android:src="@drawable/profile" />
<TextView
android:id="@+id/cardview_list_title3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/cardview_image3"
android:paddingBottom="5dp"
android:text="Viral Android"
android:textSize="24sp" />
<TextView
android:id="@+id/short_description3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/cardview_list_title3"
android:layout_toRightOf="@+id/cardview_image3"
android:text="Free android tutorials and examples for beginners and expert."
android:textColor="#8b8b8b" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/android_card_view_example4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="16dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:elevation="4dp"
android:padding="16dp">
<ImageView
android:id="@+id/cardview_image4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginRight="18dp"
android:src="@drawable/profile" />
<TextView
android:id="@+id/cardview_list_title4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/cardview_image4"
android:paddingBottom="5dp"
android:text="Viral Android"
android:textSize="24sp" />
<TextView
android:id="@+id/short_description4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/cardview_list_title4"
android:layout_toRightOf="@+id/cardview_image4"
android:text="Free android tutorials and examples for beginners and expert."
android:textColor="#8b8b8b" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
<include layout="@layout/toolbar" />
</RelativeLayout>
Use ScrollView after RelativeLayout and before linear layout. CardView are simple view that don't contains scrollable feature.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:gravity="center_horizontal"
android:orientation="vertical"
tools:context="net.example.app.AppWall">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ddd"
android:orientation="vertical"
android:padding="16dp">
<Space
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbar"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:minHeight="55dp"
android:id="@+id/topspace">
</Space>
<android.support.v7.widget.CardView
android:id="@+id/android_card_view_example"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:elevation="4dp"
android:padding="16dp">
<ImageView
android:id="@+id/cardview_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginRight="18dp"
android:src="@drawable/profile" />
<TextView
android:id="@+id/cardview_list_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/cardview_image"
android:paddingBottom="5dp"
android:text="Flipkart App"
android:textSize="24sp" />
<TextView
android:id="@+id/tvInstall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/cardview_list_title"
android:layout_toRightOf="@+id/cardview_image"
android:text="Install"
android:textColor="@android:color/holo_green_dark"
android:textSize="16sp" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/android_card_view_example1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:elevation="4dp"
android:padding="16dp">
<ImageView
android:id="@+id/cardview_image1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginRight="18dp"
android:src="@drawable/profile" />
<TextView
android:id="@+id/cardview_list_title1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/cardview_image1"
android:paddingBottom="5dp"
android:text="Viral Android"
android:textSize="24sp" />
<TextView
android:id="@+id/short_description1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/cardview_list_title1"
android:layout_toRightOf="@+id/cardview_image1"
android:text="Free android tutorials and examples for beginners and expert."
android:textColor="#8b8b8b" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/android_card_view_example2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:elevation="4dp"
android:padding="16dp">
<ImageView
android:id="@+id/cardview_image2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginRight="18dp"
android:src="@drawable/profile" />
<TextView
android:id="@+id/cardview_list_title2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/cardview_image2"
android:paddingBottom="5dp"
android:text="Viral Android"
android:textSize="24sp" />
<TextView
android:id="@+id/short_description2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/cardview_list_title2"
android:layout_toRightOf="@+id/cardview_image2"
android:text="Free android tutorials and examples for beginners and expert."
android:textColor="#8b8b8b" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/android_card_view_example3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:elevation="4dp"
android:padding="16dp">
<ImageView
android:id="@+id/cardview_image3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginRight="18dp"
android:src="@drawable/profile" />
<TextView
android:id="@+id/cardview_list_title3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/cardview_image3"
android:paddingBottom="5dp"
android:text="Viral Android"
android:textSize="24sp" />
<TextView
android:id="@+id/short_description3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/cardview_list_title3"
android:layout_toRightOf="@+id/cardview_image3"
android:text="Free android tutorials and examples for beginners and expert."
android:textColor="#8b8b8b" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/android_card_view_example4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="16dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:elevation="4dp"
android:padding="16dp">
<ImageView
android:id="@+id/cardview_image4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginRight="18dp"
android:src="@drawable/profile" />
<TextView
android:id="@+id/cardview_list_title4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/cardview_image4"
android:paddingBottom="5dp"
android:text="Viral Android"
android:textSize="24sp" />
<TextView
android:id="@+id/short_description4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/cardview_list_title4"
android:layout_toRightOf="@+id/cardview_image4"
android:text="Free android tutorials and examples for beginners and expert."
android:textColor="#8b8b8b" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</ScrollView>
<include layout="@layout/toolbar" />
</RelativeLayout>
Other thing You can do is use RecyclerView to show list of Cards.
Scrollview needs to be the parent of the rest of the views inside of ur relative layout
<RelativeLayout>
<Scrollview>
<LinearLayout>
<Cardview>
<Cardview>
</LinearLayout>
</ScrollView>
</RelativeLayout>
Respect that the scrollView must have only one direct child
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.