Handling rotation advice
<pre><code>DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);  

if(dm.densityDpi&gt;=200 &amp;&amp; dm.heightPixels&gt;790 &amp;&amp; dm.heightPixels&lt;840)
    setContentView(R.layout.login1);
else if(dm.densityDpi&gt;=200  &amp;&amp; dm.heightPixels&gt;840)
    setContentView(R.layout.login2);
</code></pre>

<p>Here I check the desplay size and give each one specific XML file (login1.xml,login2.xml). The differances between login1.xml and login2.xml is button's width and height. Is there any way to do this more effective, like to have just one login.xml and set the values from .java file.
I tried this  in java file but no result</p>

<pre><code>final Button button = (Button) findViewById(R.id.button); 
button.setwidth(100);
</code></pre>
