How can I change the font / typeface of a button in an Android widget? When working with normal view is this no problem:
// Within the app
Button myButton = (Button)rootView.findViewById(R.id.myAppButton);
myButton.setTypeface(someTypeface);
However, when working with a widget, views cannot be accessed directly but only via RemoteViews
:
// Widget
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widgetContent);
remoteViews.setTextViewText(R.id.myWidgetButton, "Some Text");
Is it somehow possible to set the typeface of the remote button as well?
There is no way to change the typeface of TextView in RemoteView .
To check properties that can be changed in RemoteView , in your case just go to Button and TextView classes and check all methods with annotation @android.view.RemotableViewMethod
. As you can see, setTypeface don't have an annotation, so it can not be changed in RemoteView anyhow
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.