【问题标题】:scrollview scrolled up when changing a value更改值时滚动视图向上滚动
【发布时间】:2020-12-21 09:20:05
【问题描述】:

大家好,我在 android studio 中遇到了问题

当我更改值或移动组件时,滚动视图滚动到布局顶部,我不知道为什么!!

这是截图

这里是xml:

        <androidx.core.widget.NestedScrollView
            android:id="@+id/scrollView2"
            android:layout_width="0dp"
            android:layout_height="0dp"
            app:layout_constraintBottom_toTopOf="@+id/btn_info_workpage"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">

              <androidx.constraintlayout.widget.ConstraintLayout
                  android:layout_width="match_parent"
                  android:layout_height="match_parent">

            ...

            </androidx.constraintlayout.widget.ConstraintLayout>
        </androidx.core.widget.NestedScrollView>

【问题讨论】:

    标签: android xml android-studio scrollview


    【解决方案1】:

    这可能是修改后的视图正在获得焦点,您可以通过在具有值更改的视图上将“android:focusable”设置为 false,同时在父视图上将相同的属性设置为 true 来停止这种情况。

    此问题中的更多信息和示例代码及其答案: How to stop EditText from gaining focus at Activity startup in Android

    【讨论】:

    • 没错,但我的布局中有任何编辑文本,并且在我的所有布局中都会发生这种情况
    • 关键是当值改变时,这同样适用于其他一些视图。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-10-30
    • 2018-03-12
    • 1970-01-01
    • 1970-01-01
    • 2015-06-04
    • 1970-01-01
    • 2016-02-01
    相关资源
    最近更新 更多