Android,ScrollView内的控件改变之后禁止自动滚动
2015-04-17 11:09
423 查看
在android的实际开发中,会要这样的情况。就是scrollView布局中,嵌套了很多布局,但是ScrollView的布局里面只能嵌套一个大的布局,而大的布局中在嵌套各种其他的布局! 可是,实际中,如ScrollView中的大的布局中嵌套了一个ListView布局,当ListView中的数据进行更新后,ScrollView就会自动滚动了!非常影响实际使用。那么如何解决呢?其实很简单!就两步!
<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/friend_scroll" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:background="@color/basecolor" android:scrollbars="none" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/basecolor" android:focusable="true" android:focusableInTouchMode="true" android:orientation="vertical" > ...... </LinearLayout> </ScrollView>
仔细看下,发现了什么没有?
android:focusable="true" android:focusableInTouchMode="true"
就是因为这两句,在scrollView中的第一层中,设置这两个属性后,不管ScrollView中的内容与控件长度如何变化,scrollView始终保持在顶端!
相关文章推荐
- 解决Android中,禁止ScrollView内的控件改变之后自动滚动
- 解决Android中,禁止ScrollView内的控件改变之后自动滚动
- 解决Android中,禁止ScrollView内的控件改变之后自动滚动
- 解决Android中,禁止ScrollView内的控件改变之后自动滚动
- android禁止ScrollView内的控件改变之后自动滚动
- 解决Android中,禁止ScrollView内的控件改变之后自动滚动
- 解决Android中,禁止ScrollView内的控件改变之后自动滚动
- 解决Android中,禁止ScrollView内的控件改变之后自动滚动 - 转
- 禁止ScrollView内的控件改变之后自动滚动
- 解决Android中ScrollView内的控件长度发生改变之后自动滚动的问题
- 禁止ScrollView内的控件改变之后自动滚动
- 禁止ScrollView内的控件高度改变之后自动滚动
- 安卓禁止ScrollView内的控件改变之后自动滚动
- Android:禁止ScrollView在子控件的布局改变时自动滚动的的方法
- 禁止ScrollView在子控件的布局改变时自动滚动的的方法
- 禁止ScrollView在子控件的布局改变时自动滚动的的方法
- 禁止ScrollView在子控件的布局改变时自动滚动的的方法
- 禁止ScrollView在子控件的布局改变时自动滚动
- 禁止ScrollView在子控件的布局改变时自动滚动的的方法
- ScrollView内的控件改变之后自动滚动的问题