Scrollview doesn't scroll to the margin at the bottom

前端 未结 3 1473
花落未央
花落未央 2020-12-16 11:16

I have a simple layout as follows :



        
相关标签:
3条回答
  • 2020-12-16 12:04

    use android:fillViewport="true" on the ScrollView may do it.

    example in this thread.

    0 讨论(0)
  • 2020-12-16 12:11

    I later found out that ,a similar situation has already been answered in the following thread https://stackoverflow.com/a/16885601/1474471 by @olefevre.

    Adding an extra LinearLayout that surrounds the current LinearLayout with a padding and removing the inner LinearLayout's layout-margin solved the problem:

    <?xml version="1.0" encoding="utf-8"?>
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
    
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#D23456"
        android:padding="10dp" >
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#FFFFFF" >
    
            <ImageView
                android:layout_width="match_parent"
                android:layout_height="800dp"
                android:src="@drawable/ic_launcher" />
        </LinearLayout>
    </LinearLayout>
    
    </ScrollView>
    
    0 讨论(0)
  • 2020-12-16 12:12

    The solution posted by @Mehmet Katircioglu works well, but you can solve the problem simply changing the android:layout_margin to android:padding, without none extra view. Like this:

    <?xml version="1.0" encoding="utf-8"?>
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
    
       <LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:background="#D23456"
          android:padding="10dp" >
    
          <!-- Your content (ImageView, buttons...) -->
      <LinearLayout/>
    
    0 讨论(0)
提交回复
热议问题