Is it possible?

Discussion in 'Application Development' started by SWhite, Aug 31, 2010.

  1. SWhite

    SWhite Member
    16

    Apr 15, 2010
    17
    1
    16
    Student, Developer
    Louisiana
    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
     

    Advertisement

  2. miXer

    miXer Well-Known Member
    53

    Aug 12, 2010
    313
    51
    53
    Norway
    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 (Text):
    1. Display display = ((WindowManager)getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    2. Window window = getWindow();
    3. window.setLayout(display.getWidth(), ViewGroup.LayoutParams.WRAP_CONTENT);
     
    SWhite likes this.

Share This Page

Loading...