AppWidget image with rounded corners

前端 未结 2 1501
遥遥无期
遥遥无期 2021-01-26 18:02

So, I am dynamically creating an image within my app by animating various Views that I display to the user in the main layout of my application.

Currently I am generati

相关标签:
2条回答
  • 2021-01-26 18:52

    Sadly, AppWidgets are quite limited in terms of views. you can only use the views that Android supports.

    The reason is that the code of the view needs to run on the container of the AppWidget, and that's a security risk, since you could get a glimpse at the private data of the app that shows it. So what Google did is that you need to prepare what to show, and when you finished, tell a restricted API how to show the AppWidget.

    So the solution would be to flush the image as it should be shown , to an imageView or something similar. I suggest to do it in the background if it has a lot to prepare.

    It all depends on your needs.

    0 讨论(0)
  • 2021-01-26 18:53

    In addition to this issue:

    'It turns out that the size of my AppWidget was clipping the image the whole time. Clipping it just enough to remove the rounded corners, and just so little as to not have been obviously clipped. So for anyone that comes across this question... all of these method's work for this purpose (just don't forget to make your AppWidget big enough to see the results).'

    Answer:

    I found it was critical to also pass the RoundedCornersDrawable through the CustomView.drawToBitMap() method before exporting it to the PNG file.

    I hope this all helps someone down the road someday!

    0 讨论(0)
提交回复
热议问题