Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

full screen layout in Scroll View

I want to have 2 layouts inside ScrollView. First layout should be on the full screen and second layout below first one. When activity starts it is not possible see second layout. Second layout is possible see after scroll screen. Please take a look on my image for better understand.

enter image description here

like image 588
Matwosk Avatar asked Apr 18 '14 16:04

Matwosk


1 Answers

Layout code: `

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="15dp" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/layout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >


    </LinearLayout>

    <LinearLayout
        android:id="@+id/layout2"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:orientation="vertical" >

        <!-- this layout can be any height you want -->

    </LinearLayout>
</LinearLayout>

</ScrollView>`

Get the device screen height: Point size = new Point(); getWindowManager().getDefaultDisplay().getSize(size); int screenHeight = size.y;

Find the LinearLayout: LinearLayout layout = (LinearLayout)findViewById(R.id.layout1);

Set the height of the layout based on the screen height you got earlier: LayoutParams params = layout.getLayoutParams(); params.height = screenHeight - getStatusBarHeight();

Done. Be sure to call all of those methods in your onCreate method.

Hope this helps!

like image 86
Ethan Thomas Avatar answered Oct 11 '22 23:10

Ethan Thomas