Fixed automatic scrolling after a control in ScrollView is disabled in Android-go

Source: Internet
Author: User

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
  1. <ScrollView
  2. android:id="@+id/scrollview1"
  3. android:layout_width="fill_parent"
  4. android:layout_height="fill_parent"
  5. android:layout_alignparentleft="true"
  6. android:layout_below="@+id/linearlayout2"
  7. android:background="@drawable/repeat_bg"
  8. android:paddingbottom="5DP" >
  9. <linearlayout
  10. android:layout_width="match_parent"
  11. android:layout_height="match_parent"
  12. android:orientation="vertical"
  13. android:paddingleft="10DP"
  14. android:paddingright="10DP"
  15. android:focusable="true"
  16. android:focusableintouchmode="true"
  17. android:paddingtop="15DP" >
  18. <!--above these two lines is control ScrollView
  19. android:focusable="true"
  20. android:focusableintouchmode="true"
  21. Not automatic key!!-->
  22. <linearlayout
  23. android:layout_width="match_parent"
  24. android:layout_height="wrap_content"
  25. android:orientation="vertical" >
  26. <ListView
  27. android:id="@+id/lv_gc"
  28. android:layout_margintop="5DP"
  29. android:layout_width="match_parent"
  30. android:layout_height="20DP"
  31. android:background="#aaffffff"
  32. android:divider="#666"
  33. android:scrollbars="none|vertical" >
  34. </ListView>
  35. </linearlayout>
  36. </linearlayout>
  37. </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
    1. android:focusable="true"
    2. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.