Adjust scrollview dynamically
<p>I want the scrollview to fit half of my screen regardless of the android device it's running...how can i do that dynamically . I tried something like this but i am stuck</p>

<pre><code>Display display = ((WindowManager) getSystemService(this.WINDOW_SERVICE)).getDefaultDisplay();
    int displayHeight = display.getHeight();
    Log.w("DHA","test 3");
    ScrollView sv = (ScrollView)findViewById(R.id.ScrollView01);
    Log.w("DHA","test 2");
    sv.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, displayHeight - 10));
</code></pre>

<p>The application closes unexpectedly after the last line</p>
