如何在 android 小部件中设置 RecyclerView

来自:https://developer.android.com/training/material/列表卡片.html

我想在主屏幕的小部件中设置 RecyclerView.有可能吗,如果可以,该怎么做?请给一些样品.

I want to set RecyclerView in widget on home screen. Is it possible, and if it is, how to do it? Give some samples please.

推荐答案

不支持RecyclerView 用作RemoteView.请参阅 CreatingLayout

RecyclerView is not supported to be used as a RemoteView. See CreatingLayout

RemoteViews 对象(以及相应的 App Widget)可以支持以下布局类:

A RemoteViews object (and, consequently, an App Widget) can support the following layout classes:

框架布局
线性布局
相对布局
网格布局

FrameLayout
LinearLayout
RelativeLayout
GridLayout

以及以下小部件类:
模拟时钟
按钮天文台表
图像按钮
图像视图
进度条
文本视图
ViewFlipper
列表视图
网格视图
堆栈视图
AdapterViewFlipper

And the following widget classes:
AnalogClock
Button Chronometer
ImageButton
ImageView
ProgressBar
TextView
ViewFlipper
ListView
GridView
StackView
AdapterViewFlipper

相关文章