【发布时间】:2021-09-08 13:42:54
【问题描述】:
如果我第一次单击 text2 或单击 text1 后单击 text2 时,ScrollView 似乎正在将 text2 滚动到顶部。如果我将android:descendantFocusability="blocksDescendants" 放在LinearLayout 中,则不会发生这种滚动,但我无法选择文本。
我想要的很简单:我不想要这种自动滚动。禁用ScrollView 的这种行为是不可能的,我必须从头开始创建自己的滚动视图类吗?如果不可能,请把它写成答案,这样我就可以放弃了。
<?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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:text="I am text 1. Click me."
android:textColor="@color/black"
android:textIsSelectable="true"
android:background="#FF0000"
android:layout_width="match_parent"
android:layout_height="400dp"/>
<TextView
android:text="I am text 2. Click me."
android:textIsSelectable="true"
android:background="#00FF00"
android:textColor="@color/black"
android:layout_width="match_parent"
android:layout_height="1000dp"/>
</LinearLayout>
</ScrollView>
【问题讨论】:
标签: android android-layout android-widget android-scrollview android-scroll