And*_*dre 5 android scrollview textview android-studio
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/solutions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lineSpacingMultiplier="1.2"
android:textAppearance="@style/TextAppearance.AppCompat"
android:textIsSelectable="true"
android:textSize="18sp"
tools:text="1. 1+2+3 = 6"/>
</HorizontalScrollView>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
android:textIsSelectable="true"添加后TextView,TextView会自动滚动到底部。但是我不想要这种行为。
raf*_*007 -1
试试这个:添加
android:focusable="false"
android:focusableInTouchMode="false"
<TextView
android:id="@+id/solutions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:focusableInTouchMode="false"
android:lineSpacingMultiplier="1.2"
android:text="1. 1+2+3 = 6"
android:textAppearance="@style/TextAppearance.AppCompat"
android:textIsSelectable="true"
android:textSize="18sp" />
Run Code Online (Sandbox Code Playgroud)
解决方案的原因是:
当您使用 时android:textIsSelectable="true",您实际上是在调用TextView.setTextIsSelectable(true),这会同时调用View.setFocusable和View.setFocusableInTouchMode....并导致scrollview自动滚动文本。
| 归档时间: |
|
| 查看次数: |
483 次 |
| 最近记录: |