android - 每次更新视图时,Android 垂直滚动视图会自动移动到顶部
问题描述
我在 Android 中的滚动条,每次更新我的 ConstraintLayout 中的 TextView 时向上滚动。许多 TextView 每秒都会使用来自外部设备的值进行更新,并且滚动条每秒都会返回到顶部位置。我只是希望对于 TextView 的每次更新,都没有滚动。滚动只能在我触摸时发生。
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/ScrollView_example"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true"
android:descendantFocusability="beforeDescendants"
android:fillViewport="true" >
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/Constraint_example"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/txt1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:text="My TextVIEW1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
请问,有人可以帮我吗?非常感谢。
解决方案
推荐阅读
- php - Symfony 在成功登录后重定向到登录...有时
- sql - PostGIS Raster ST_Union:它如何管理无数据
- pybind11 - 以数组作为类属性的pybind
- php - Imagick 最大资源在 php 脚本中与 php 命令行不同
- postgresql - postgreSQL - 按唯一 ID 计算小时数等
- compiler-errors - 此文件不属于任何项目 在 clion 中打开项目时代码洞察可能无法正常工作
- database - 将 Hive 列从字符串转换为具有 NaT 值的时间戳
- visual-studio - Visual Studio 市场下滑
- python - 使用 Pyinstaller 或 Cython 从 Python 模块创建可执行文件
- vba - 在存储为变量的表单上调用 .setFocus 时出错