kitkat 中的 CardView 和 RecyclerView
CardView and RecyclerViews on kitkat
我计划在我当前的应用程序中使用 CardView
和 RecyclerView
来替换 GridView
。但是,这些视图(CardView
和 RecyclerView
)在 Lollipop (5.0)
及以后的版本上受支持。
我想知道,如果用户的操作系统低于 Lollipop
,比如 Kitkat
,会发生什么情况?
我如何支持该设备?
它们作为 "support" 或 "compat" 软件包的一部分出现,因此这两个组件也应该在 pre-kitkat 版本
中可用
它们是 Android Support libraries
v7 的一部分。您可以通过在 gradle 文件中添加以下支持库来使用它们:
dependencies {
...
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
}
并且您可以从 Support Library
:
定义一个 RecyclerView
<android.support.v7.widget.RecyclerView
android:id="@+id/my_recycler_view"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
有关更多信息,请查看官方指南:
http://developer.android.com/training/material/lists-cards.html
我计划在我当前的应用程序中使用 CardView
和 RecyclerView
来替换 GridView
。但是,这些视图(CardView
和 RecyclerView
)在 Lollipop (5.0)
及以后的版本上受支持。
我想知道,如果用户的操作系统低于 Lollipop
,比如 Kitkat
,会发生什么情况?
我如何支持该设备?
它们作为 "support" 或 "compat" 软件包的一部分出现,因此这两个组件也应该在 pre-kitkat 版本
中可用它们是 Android Support libraries
v7 的一部分。您可以通过在 gradle 文件中添加以下支持库来使用它们:
dependencies {
...
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
}
并且您可以从 Support Library
:
RecyclerView
<android.support.v7.widget.RecyclerView
android:id="@+id/my_recycler_view"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
有关更多信息,请查看官方指南:
http://developer.android.com/training/material/lists-cards.html