Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>btn = (Button) findViewByID(R.id.button_study); btn.getLayoutParams().height = x; btn.getLayoutParams().width = x; btn.setLayoutParams(btn.getLayoutParams); </code></pre> <p>Using this code, you can set the height and width of the button. Also, this would avoid the parent view parsing conflict.</p> <p>Also, you can get the size of screen and then set size of button accordingly:-</p> <p>For API&lt;13</p> <pre><code>Display display = getWindowManager().getDefaultDisplay(); int screenWidth = display.getWidth(); int screenHeight = display.getHeight(); //not required, just to inform int x = (int) screenWidth/10; //replace 10 by scaling factor btn = (Button) findViewByID(R.id.button_study); btn.getLayoutParams().height = x; btn.getLayoutParams().width = x; btn.setLayoutParams(btn.getLayoutParams); </code></pre> <p>For API>=13</p> <pre><code>Point size = new Point(); display.getSize(size); int screenWidth = size.x; int screenHeight = size.y; //not required, just for info int x = (int) screenWidth/10; //replace 10 by scaling factor btn = (Button) findViewByID(R.id.button_study); btn.getLayoutParams().height = x; btn.getLayoutParams().width = x; btn.setLayoutParams(btn.getLayoutParams); </code></pre> <p>to check for API level at runtime, use</p> <pre><code>if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB_MR2) { //&lt;code&gt; if API&gt;=13 (HONEYCOMB_MR2 is API 13) } else { //&lt;code&gt; if API&lt;13 } </code></pre> <p>Hope it helps. Happy Programming :)</p>
    singulars
    1. This table or related slice is empty.
    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. This table or related slice is empty.
    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