Problem:
Recently writing a program interface, there is a scrollview, where there is a piece of content that needs to be loaded online.
When the content is loaded, the length of the content in the ScrollView changes, and ScrollView automatically rolls down as shown:
The scrolling experience is particularly bad, so avoid this situation. That is, whatever the content of the ScrollView, keep it to the top.
Workaround:
Just write the structure of my XML file briefly:
[HTML]View PlainCopy
- <ScrollView
- android:id="@+id/scrollview1"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:layout_alignparentleft="true"
- android:layout_below="@+id/linearlayout2"
- android:background="@drawable/repeat_bg"
- android:paddingbottom="5DP" >
- <linearlayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- android:paddingleft="10DP"
- android:paddingright="10DP"
- android:focusable="true"
- android:focusableintouchmode="true"
- android:paddingtop="15DP" >
- <!--above these two lines is control ScrollView
- android:focusable="true"
- android:focusableintouchmode="true"
- Not automatic key!!-->
- <linearlayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical" >
- <ListView
- android:id="@+id/lv_gc"
- android:layout_margintop="5DP"
- android:layout_width="match_parent"
- android:layout_height="20DP"
- android:background="#aaffffff"
- android:divider="#666"
- android:scrollbars="none|vertical" >
- </ListView>
- </linearlayout>
- </linearlayout>
- </ScrollView>
As the above code, the first content in my ScrollView is LinearLayout, and below is a linearlayout wrapped listview.listview that is variable in length.
Add the code to the LinearLayout:
[HTML]View PlainCopy
- android:focusable="true"
- Android:focusableintouchmode="true"
Problems can be solved, welcome to exchange.
Reprint please specify from: http://blog.csdn.net/icyfox_bupt/article/details/15026299
Fixed automatic scrolling after a control in ScrollView is disabled in Android-go