SetTextSize (float) not supported in remote TextView?

I am trying to set the text size of a remote TextView in a widget as follows:

RemoteViews rv = new RemoteViews(mContext.getPackageName(), layoutId); rv.setFloat(R.id.subject, "setTextSize", 10f); 

While I can set other attributes, such as the color of the text or change the appearance of the view, when using setTextSize, inflation does not occur with the following error message (without a stack trace):

 Error inflating RemoteViews at position: 1, using loading view instead android.widget.RemoteViews$ActionException: view: android.widget.TextView doesn't have method: setTextSize (float) 

setTextSize (float) has the @RemotableViewMethod annotation, so it should be supported, but the method was not even found (the difference between “has no method” and “not supported”) does not exist.

Why doesn't he find a method when he's clearly there? The presentation of the setTextViewTextSize () method for RemoteViews in API 16 might be an indicator that something is wrong with my approach? Any help would be greatly appreciated.

+4
source share
1 answer

You must use the int type in the third parameter. So, remove the 'f', which makes it an explicit float.

 rv.setFloat(R.id.subject, "setTextSize", 10); 
+3
source

All Articles