Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Is there a way to get the size of a RemoteViews object?

In my app widget, I have a LinearLayout whose height and width are set to fill_parent. Is there a way to get at runtime, the actual size that has been allocated to this view?

like image 747
Tom Avatar asked Apr 22 '11 12:04

Tom


1 Answers

The app widget meta data XML file determines the overall size of your widget; you must design your layouts with that size in mind. If you are implementing multiple size widgets, you will need a separate meta data and layout for each one.

The app widget system uses an abstract "grid units" that you can turn into DP, see this page for details. If you set the size incorrectly, it will just "truncate" to the nearest grid size on your behalf (and your layout will look "bad").

Android 3 and 4 give you more possibility for sizing.

like image 133
escape-llc Avatar answered Oct 22 '22 13:10

escape-llc