问题出现的原因是因为ScrollView中子布局的的焦点的变化导致ScrollView自动的滑动 。所以解决方法就是让ScrollView中的最外层子布局焦点固定。
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:focusable="true"
android:focusableInTouchMode="true">
</LinearLayout>
</ScrollView>
在LinearLayout中加入
android:focusable=”true”
android:focusableInTouchMode=”true”
便能解决问题。
本文介绍了一个关于ScrollView在Android应用中因子布局焦点变化导致自动滚动的问题,并提供了解决方案:通过设置最外层子布局的focusable及focusableInTouchMode属性为true来固定焦点。

2640

被折叠的 条评论
为什么被折叠?



