Android Development Learning Note Series (3)--scrollview and Horizontalscrollview

Source: Internet
Author: User

ScrollView and Horizontalscrollview

This is a scrolling view, that is, if you do not have so much content in your UI, and you have set the Px,ok for your UI, then we do not want to compress it in the process of adapting to the screen, so we can use the ScrollView space to package!

Note that it is worth mentioning that it can only wrap one component , so you have to use only one layout to lay it out in this process!

Of course, the above is a vertical layout, if you want to use a horizontal layout, then you can use horizontalscrollview!

Detailed description of the above two controls ScrollView

ScrollView, through the inheritance of official documents, can be seen that it inherits from Framelayout, so it is a special type of framelayout because it can use the user scroll to display a list of views that occupy more space than the physical display. It is important to note that ScrollView can only contain one child view or view group, and in the actual project, it usually contains a vertical linearlayout.

It is important to note that ScrollView cannot be used with the ListView because the ListView has already handled the vertical scrolling, forcing the vertical scrolling effect if the contents of the ListView are larger than the contents of the physical view. So there is no point in using ScrollView and ListView mixing, for the ListView, see my other blog: Android–ui's listview. ScrollView also need to pay attention to the edittext of the multi-line input of the scrolling effect, but also can not be mixed, if the ScrollView contains multiple lines of EditText, the edittext of the own scrolling effect will be invalidated. The central idea is that ScrollView is a container for scrolling views, and it is not possible to mix it with some controls that have their own scrolling effect.

Under the Android platform, there is a Horizontalscrollview container similar to ScrollView, which has the opposite effect on ScrollView, which is mainly applied to horizontal scrolling, Understand ScrollView basically understand the Horizontalscrollview, so here focus on the use of ScrollView.

ScrollView is actually a layout, so there is basically not much of your own methods or attributes that need to be specifically explained. Here is a demo to illustrate the use and effects, here are 10 images, which need to be placed in the RES/DRAWABLE-HDPI directory.

Layout file xml:

Horizontalscrollview

For Horizontalscrollview, in fact all ideas are similar to ScrollView, the only difference is that Horizontalscrollview support horizontal scrolling. In the above example, just change the peripheral scrollview to Horizontalscrollview, and then wrap the LinearLayout android:o The Rientation property is set to horizontal to achieve a horizontal scrolling effect.

The above is borrowed from the Friends of the blog, because this is not necessary to introduce in detail, in this very grateful to the friends of the park to share, here, specifically posted the source of the above resources ——-Android–ui ScrollView

If someone does not say I shameless to take the blog of the Friends of the blogger reproduced words, in this expressed deep regret, I admit reproduced! But I will still follow my own writing principles: share what I want to share, write what I want to write, quote will be written in the same place, live up to any one willing to share, so that everyone can learn and work in peace!

Android Development Learning Note Series (3)--scrollview and Horizontalscrollview

Related Article

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.