I am trying to render a RemoteViews instance onto a Canvas, like I do with a regular View. I use
RemoteViews.apply(context, null)
and it returns a FrameLayout with all the views nested and properly measured (location and size is correct,) but after using .draw on the returned view, it renders all elements with no values -- TextViews are empty, AnalogClock is reset at 00:00 and so on.
Any ideas? I'm lost :(
Not sure if the question is still actual. Nevertheless here is my experience with RemoveViews. It appears you cannot just call draw()
on the returned view. You have to add this view to a parent container to make it a part of global view hierarchy. For instance, you have an Activity
with a single FrameLayout
in it. Your code will look like this.
FrameLayout parent = findViewById(R.id.container);
View view = RemoteViews.apply(getActivity(), parent);
parent.addView(view);
Now you should be able to see tests. If you set listeners, they will work properly too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With