Ext.: http://my.oschina.net/cjk035/blog/127445
Recently doing a project, above is a linearlayout layout, the following is a Baidu map of the Mapview control, Mapview control of the height of the larger, resulting in the entire page content beyond the screen display area, so on the outside set a ScrollView, But new problems arise, each time you enter the page, because the map loading caused scrollview always automatically scroll to the bottom, the above LinearLayout area only shows the following part, in order to solve this problem I used the scrollview. Fling (0), Scrollview.scrollto (0,0); but none of them worked, but the seemingly simple problem became so tight that it took a long time to find the best solution:
Override the following method in ScrollView and set its return value to 0.
@Override
protected int Computescrolldeltatogetchildrectonscreen (rect rect) {
return 0;
}
Ext.: http://blog.csdn.net/icyfox_bupt/article/details/15026299
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.
Resolves automatic scrolling after controls in ScrollView are disabled in Android