Full Screen Scrolling

I want to have 2 layouts inside ScrollView. The first layout should be in full screen and the second layout below the first. When the action begins, it is impossible to see the second layout. The second layout can be seen after the scroll screen. Please take a look at my image to better understand.

enter image description here

+6
source share
1 answer

Layout format: `

<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 device screen height: Point size = new Point(); getWindowManager().getDefaultDisplay().getSize(size); int screenHeight = size.y; Point size = new Point(); getWindowManager().getDefaultDisplay().getSize(size); int screenHeight = size.y;

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

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

Done. Be sure to call all of these methods in the onCreate method.

Hope this helps!

+9
source

All Articles