2019年10月10日星期四

Android Studio 如何在xml layout中应用Recyclerview

此文是下述链接的后续。
Android Studio 如何在xml layout中应用Cardview
注意的是Android Studio 3.5版本默认使用androidx。
在app level的build.gradle添加下文。

dependencies {
    ......
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
}

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout  xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"

    >
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        >

        <!-- A RecyclerView with some commonly used attributes -->
        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/my_recycler_view"
            android:scrollbars="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
    </LinearLayout >


</RelativeLayout >

没有评论:

发表评论