• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Is it possible?

SWhite

Newbie
Is it possible to set a layout's width as a percentage of the overall screen size?

If so, what param and what entry?

Thanks
 
You can use this code to get the width size of the screen. This way you can set the percentage/size you want. This code sets my dialog width to screens width:
Code:
Display display = ((WindowManager)getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
Window window = getWindow();
window.setLayout(display.getWidth(), ViewGroup.LayoutParams.WRAP_CONTENT);
 
Back
Top Bottom