I’m creating some custom remoteViews, In order to draw custom views and layouts to a bitmap as wide as the notification panel I need its exact width.
As every vendor changes the width of the notification panel and in most cases it will changes based on orientation, It’s difficult to find a regular pattern on that.
Is there any way to get its width?
The pink part is pure remoteViews and the bottom part is an imageview which I draw my custom view to it, since I don’t have the parent width, all the child views get crumble together.
The easiest way is to use LinearLayout with
android:layout_width="match_parent", and to put
android:layout_width="0dp" for every view in that layout. That means that every view in that layout will have same width. More about it you can read here.
UPDATE: In here it says that notification tray width is 478dp.
So, try with that. Maybe some manufactures have different size, but this is good number to start with :).
You can try this to get the width and calculate your custom layout
DisplayMetrics displaymetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); int height = displaymetrics.heightPixels; int width = displaymetrics.widthPixels;
Use the width to calculate your custom layout