Android ScrollView content showed incomplete


ScrollView LinearLayout could show the normal, but in addition eighteenth line statement:
android:layout_marginTop="20dp"
Later, it came out the 20dp margin, this is right.
But why there is less 20dp? To scroll procrastinate not to the end, so the bottom button shows the insufficiency.

What's this about, Harvey? The XML code is as follows:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<ScrollView
android:layout_width="200dp"
android:layout_height="200dp"
android:scrollbars="vertical"
android:background="@android:color/background_dark" >

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:orientation="vertical"
android:gravity="center_horizontal"
android:background="@android:color/holo_blue_light" >

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="What's next" />

<Button
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="What's next" />

<Button
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="What's next" />

<Button
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="What's next" />

</LinearLayout>
</ScrollView>
</RelativeLayout>

Started by Samuel at December 03, 2016 - 1:35 PM

Plus layout_marginBottom

Posted by Patrick at December 08, 2016 - 1:43 PM

Do you know why will appear this kind of phenomenon?? Strange

Posted by Samuel at December 20, 2016 - 2:34 PM

This is because, after you add marginTop, scrollView initial showing the location of moving down the 20dp, if you want to let him display properly, must be set up the initial scrollView in the code inside the display position on it. mScrollView.smoothScrollTo(0,0).

Posted by Cheney at January 03, 2017 - 3:11 PM

You can set the Scrollview paddingTop=20, do not set inside the marginTop, try

Posted by Clarence at January 05, 2017 - 3:40 PM

The knot MLGB paste.

Posted by Wesley at January 06, 2017 - 3:45 PM