Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Android notification panel width

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?

enter image description here enter image description here

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.

like image 468
M. Reza Nasirloo Avatar asked Jul 20 '16 18:07

M. Reza Nasirloo


1 Answers

The easiest way is to use LinearLayout with android:orientation="horizontal" and android:layout_width="match_parent", and to put android:layout_weight="1" and 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 :).

like image 61
Vladimir Jovanović Avatar answered Oct 24 '22 05:10

Vladimir Jovanović