1

I'm trying to use a custom font with the text in my Widget. Since the RemoveViews is very limited and doesn't support custom fonts in the TextView options, I found this post that showed a clever way of getting around this. Essentially, instead of using a TextView I use an ImageView and render a bitmap of the text in the custom font and set the ImageView's bitmap to the rendered image. Now the only problem is that I need to determine the width to render the Bitmap so it fits perfect in the fill_parent on the ImageView. So how do I get the width of a widget?

Community
  • 1
  • 1
Brian
  • 7,955
  • 16
  • 66
  • 107

1 Answers1

1

I'm trying to use a custom font with the text in my Widget.

Note that the correct term is "app widgets". Widgets are subclasses of View. App widgets are the things that go on the home screen. See: http://developer.android.com/guide/topics/appwidgets/index.html

So how do I get the width of a widget?

You don't. You know what you asked for via your metadata. What you wind up with is up to the home screen implementation, and there is no way to retrieve that information. That goes double for widgets that the user resizes, either because you indicated that you support resizing, or the home screen just decided to roll that feature themselves.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • I see, well in that case, might you have a solution for my initial problem of trying to use custom fonts in my app widget? – Brian Apr 02 '12 at 23:39