I don't understand why google decided to not implement support for custom views or even support for the ones bundled in the support library when designing widgets, and instead it decided to rely on RemoteViews
Widgets are such a big part of users interaction with the app, I'm sure many developers found themselves forced to change plans due to this limitation
Is there a specific reason why this was made, maybe related to performances or?
For example, now i would like to implement a recycler view in one widget but I can't, and I don't understand why it has to be so hard to design one and with so much boilerplate code
Widgets are such a big part of users interaction with the app
Few apps implement app widgets.
Is there a specific reason why this was made
Both the host of the app widget (e.g., home screen/launcher) and the publisher of the app widget need to agree on what UI elements can be used and how they can be configured.
For example, you seem to want to use a RecyclerView
. That's fine, however, your app does not render the app widget. The host is the one that needs to render the UI of the app widget. So, if you were to use a RecyclerView
, your app widget would fail on all hosts that lack RecyclerView
support for app widgets. This includes:
All hosts that have not been updated since before RecyclerView
was introduced (e.g., home screens on older devices)
All hosts that did not bother to bundle in RecyclerView
in their apps
All hosts that did not bother to bundle in whatever the code would be that would cause app widget rendering to support RecyclerView
This coordination gets very complex with hundreds or thousands of hosts and tens or hundreds of thousands of app widgets.
Plus, where does it stop? You think that using RecyclerView
is reasonable, and the next person will think that using Facebook's Litho is reasonable, and the person after that will think that using some obscure custom View
found on the Android Arsenal is reasonable.
The simple approach for ensuring this agreement is to use a common definition in the framework classes, like RemoteViews
, so there is a guaranteed-consistent definition between host and app widget provider. However, RemoteViews
is difficult to change in a backwards-compatible fashion, which is why Google has only done it once to date (API Level 11, with the introduction of AdapterView
-based options, such as ListView
). And framework classes know nothing about libraries, such as those providing RecyclerView
or Litho.