Remove the scroll bar from the HorizontalScrollView of the Android control.

Source: Internet
Author: User

Remove the scroll bar from the HorizontalScrollView of the Android control.

By default, the content in the HorizontalScrollView control is scroll, and a scroll bar appears. To remove the scroll bar, you only need to add an android in <HorizontalScrollView/>: scrollbars = "none ".

 

If you want to implement this in the code, click the left (right) button [btnLeft (btnRight)], and the content in the scroll bar will scroll to the left to the right [horizontalScrollViewMM ]. The Code is as follows:



Scroll to the left of the scroll bar:

btnLeft.setOnClickListener( new View.onClickListener(){                   horizontalScrollViewMM.arrowScroll(View.FOCUS_LEFT);      });

Scroll to the right of the scroll bar:

 btnRight.setOnClickListener( new View.onClickListener(){      horizontalScrollViewMM.arrowScroll(View.FOCUS_RIGHT);     });




How can I control the scroll bar of Android HorizontalScrollView in JAVA code?

SV. setHorizontalScrollBarEnabled (false );
 
Question about the horizontal scroll bar of android scrollview

If you include the content in the ScrollView, the scroll bar will automatically appear when the content exceeds the height.

In addition, when you use the control HorizontalScrollView to wrap your content,
If your content is assumed to be a LinearLayout, when the width of LinearLayout exceeds the screen, a scroll bar is automatically generated. When you drag the mouse, the effect is the same as that of scrollView.

Example:
Vertical scroll
<ScrollView>
<LinearLayout...>
<TextView.../>
<TextView.../>
<TextView.../>
<TextView.../>
</LineraLayout>
</ScrollView>

Die-Rolling
<HorizontalScrollView>
<LinearLayout...>
<TextView.../>
<TextView.../>
<TextView.../>
<TextView.../>
</LineraLayout>
</HorizontalScrollView>

Sometimes it can even be horizontally and vertically supported. You only need to design it properly. Note that only one control can be added to the ScrollView, and no more than two

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.