Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Short answer: <code>LinearLayout</code>.</p> <p>Long answer is here:</p> <p><a href="https://stackoverflow.com/questions/6557220/defining-a-percentage-width-for-a-linearlayout?rq=1">Defining a percentage width for a LinearLayout?</a></p> <p>There are also ways of getting density at runtime, but the above is easier in the long run.</p> <p>Get ready for some pseudo-xml!</p> <pre><code>&lt;LinearLayout double fill parent, vertical&gt; &lt;RelativeLayout w = 0, h = 0, weight smallish&gt; &lt;Button A /&gt; &lt;/RelativeLayout&gt; &lt;LinearLayout w = 0, h = 0, weight largish. horizontal&gt; &lt;!-- maybe you want these to be RelativeLayout and set the buttons as centerHorizontalInParent="true" --&gt; &lt;LinearLayout w = 0, h = 0, weight whatever 20% is&gt; &lt;Buttons with some padding/margins&gt; &lt;/LinearLayout&gt; &lt;Some kind of spacer, or just pad the LLs /&gt; &lt;LinearLayout repeat above /&gt; &lt;/LL&gt; &lt;/LL&gt; </code></pre> <p>Edit:</p> <p>If you are bent on doing alot of dynamic resizing, I have this custom class for getting screen size:</p> <pre><code>public class ScreenGetter { private float pixHeight; private float pixWidth; private float dpHeight; private float dpWidth; private float density; public ScreenGetter (Context context){ Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay(); DisplayMetrics metrics = new DisplayMetrics (); display.getMetrics(metrics); pixHeight = metrics.heightPixels; pixWidth = metrics.widthPixels; density = context.getResources().getDisplayMetrics().density; dpHeight = pixHeight / density; dpWidth = pixWidth / density; } public float getPixHeight(){return pixHeight;} public float getPixWidth(){return pixWidth;} public float getDpHeight(){return dpHeight;} public float getDpWidth(){return dpWidth;} public float getDensity(){return density;} } </code></pre> <p>Obviously you'll need to do some math to figure out what you want at different sizes and densities. You also need to account for parts of the screen you are not using (ActionBar, etc.)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload