ScrollView не выполняет прокрутку вниз
У меня есть определенная проблема в моей работе. ScrollView не прокручивается вниз.
У меня есть скриншот для вас.
![enter image description here]()
Если вы посмотрите на полосу прокрутки scrollView, вы увидите, что она не прокручивается вниз.
Вот мой XML-макет scrollView:
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:fillViewport="true"
android:layout_below="@+id/step2_header" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp" >
<TextView
android:id="@+id/step2_headerText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:gravity="center"
android:text="@string/Schritt2"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/dark_blue"
android:textStyle="bold|italic" />
<ImageView
android:id="@+id/step2_image"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:layout_below="@+id/step2_headerText"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_marginTop="10dp"
android:src="@drawable/menu_leiste" />
<TextView
android:id="@+id/step2_infoText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/step2_image"
android:text="@string/step2Text"
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageView
android:id="@+id/step2_but1Img"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_below="@+id/step2_infoText"
android:layout_marginTop="10dp"
android:src="@drawable/menu_leiste_selector" />
<TextView
android:id="@+id/step2_but1Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/step2_but1Img"
android:layout_alignParentLeft="true"
android:layout_alignTop="@+id/step2_but1Img"
android:layout_marginLeft="10dp"
android:gravity="center"
android:text="@string/step2But1Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/white" />
<ImageView
android:id="@+id/step2_but1ArrowImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:layout_alignBottom="@+id/step2_but1Img"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/step2_but1Img"
android:src="@drawable/location_web_site" />
<ImageView
android:id="@+id/step2_but2Img"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_below="@+id/step2_but1Img"
android:layout_marginTop="10dp"
android:src="@drawable/menu_leiste_selector" />
<TextView
android:id="@+id/step2_but2Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/step2_but2Img"
android:layout_alignParentLeft="true"
android:layout_alignTop="@+id/step2_but2Img"
android:layout_marginLeft="10dp"
android:gravity="center"
android:text="@string/step2But2Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/white" />
<ImageView
android:id="@+id/step2_but2ArrowImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:layout_alignBottom="@+id/step2_but2Img"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/step2_but2Img"
android:src="@drawable/location_web_site" />
</RelativeLayout>
</ScrollView>
Как я могу это исправить?
Ответы
Ответ 1
Проблема заключается в android: layout_margin = "10dp" в RelativeLayout из SrcollView
Заменить
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">
с
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp" >
Ответ 2
использовать в scrollView xml
android:paddingBottom="10dp"
он сдвинет содержимое прокрутки до 10 дп вверх, а не VIEW.
Ответ 3
Для меня у меня есть другое конкретное решение, если родительский макет ScrollView - ConstraintLayout. Если это так, нам не нужно устанавливать отступы или поля.
<androidx.constraintlayout.widget.ConstraintLayout
....>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="<if there is any element before this this scrollview >">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
Ответ 4
Для меня, установка явной высоты для некоторых из моих внутренних элементов помогла.
Ответ 5
Я страдал от той же проблемы. Попробуйте добавить больше отступов внизу scrollView. Это работает для меня.
android:paddingBottom="50dp"
Ответ 6
Попробуйте вместо этого NestedScrollView
.
Я сам несколько раз сталкивался с этой проблемой, и хотя я просто добавил дополнительные отступы внизу, чтобы скрыть тот факт, что представление прокрутки идет "за" нижней панелью, лучшим решением будет использование NestedScrollView, как упомянуто в этом ответе: fooobar.com/questions/11813457/...
Ответ 7
Это может быть проблема с вашим дизайном макета. если вы добавите поле для представления, то оно будет ясно видно. так
В scrollview add
android:layout_marginBottom="30dp"