Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I'm trying to create a widget for an app. the widget has main 4 image buttons with background images.

The widget connects to a BLE device. I want to check onUpdate method if the device is connected do nothing, if not change the tint color to gray and disable the buttons. As far as I know the app widget [UI] manipulation is limited by the methods of the RemoteViews class.

I managed to set the background image using setBackgroundResource but not the tint color

What I have tried:

I have used setInt method like below, but not working
remoteViews.setInt(R.id.btn_start,"setColorFilter",  Color.GRAY);

Any suggestions?
Posted
Updated 27-Aug-20 15:22pm
v2
Comments
David Crow 21-Aug-18 10:14am    
I know what background and font color is, but what is tint color?
Samira Radwan 27-Aug-18 10:48am    
please refer to the following link:
https://developer.android.com/reference/android/widget/ImageView.html#attr_android:tint
I'm trying to change the image color under certain condition. it works fine from activity but from widget it's not.
David Crow 27-Aug-18 10:54am    
What if you used setColorFilter() instead?
Samira Radwan 28-Aug-18 15:33pm    
I have tried this. The only thing that workss is button's background color!!
I believe what I'm going to do is create the same image with grey-scale and replace button's background image like : views.setInt(R.id.btn_start,"setBackgroundResource", R.drawable.button_start_grey);
more images but it works, I guess!
David Crow 28-Aug-20 8:26am    
Is this the signature of the setColorFilter() method you are meaning to call:

https://developer.android.com/reference/android/graphics/drawable/Drawable#setColorFilter(android.graphics.ColorFilter)

If so, will Color.GRAY work as the ColorFilter parameter?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900