Is it possible?


Last Updated:

  1. SWhite

    SWhite Member This Topic's Starter

    Joined:
    Apr 15, 2010
    Messages:
    17
    Likes Received:
    1
    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

    Joined:
    Aug 12, 2010
    Messages:
    313
    Likes Received:
    51
    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...