Changing app widget background color programmatically

后端 未结 5 1749
感动是毒
感动是毒 2021-01-04 12:17

How do I set the background color of the home screen app widget programmatically?

相关标签:
5条回答
  • 2021-01-04 12:27

    Remember widget is remoteView. You have very limited resource to updates UI of widget and not directly.

    You can try :

    remoteViews.setInt(viewId, "setBackgroundColor", Color.BLACK);
    

    I never used it but i guess it may be the way.

    I guess you need to change color dynamically.

    0 讨论(0)
  • 2021-01-04 12:34

    Find the following code..

    code:

      Button button;
    
        //to change background color..
    
        button.setBackgroundColor(Color.Yellow);
    
    0 讨论(0)
  • 2021-01-04 12:42

    use

     Yourwidget.setBackgroundColor(Color.RED);
    

    hope help

    0 讨论(0)
  • 2021-01-04 12:48
    Widget.setBackgroundColor(Color.LTGRAY);
    
    0 讨论(0)
  • 2021-01-04 12:51

    You can change color of ImageView image in "RemoteViews" by doing this:

    remoteviews.setInt(viewid, "setColorFilter", color);
    
    0 讨论(0)
提交回复
热议问题