Hi I have a problem creating a custom view for an Android application. My custom view wants to use if permitted the maximum screen width. I couldn't find any way to retrieve this value.
Can anybody point me to the right method?
Try
mWinMgr = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
int displayWidth = mWinMgr.getDefaultDisplay().getWidth();
where context is Context
instance.
By default, the FrameLayout
in which your layout is kept, fills the whole display horizontally (vertically you can have status bar). So you can set the maximum possible width by using android:layout_width="fill_parent"
correctly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With