Android implements ScrollView automatic scrolling instance code _android

Source: Internet
Author: User

Sometimes you need to add data dynamically, the screen is full, and the data needs to be displayed. Here the main understanding of the Scrollto (0, off) method of the meaning of shouting usage.

The meaning does not say, probably the meaning is like this.

Here's how he uses it:

Copy Code code as follows:

private void Searchresultshow () {

TextView TextView = new TextView (afsearchactivity.this);
Textview.settext ("Text View");
Linearlayout.layoutparams p = new Linearlayout.layoutparams (
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT
);
Textview.setpadding (30, 15, 0, 15);
Textview.settextsize (30);
Textview.settextcolor (Color.White);
Add a TextView to the linear layout
Layout.addview (TextView, p);

ImageView ImageView = new ImageView (afsearchactivity.this);
Imageview.setimageresource (R.drawable.im_dottend_line);

Add a ImageView to the linear layout
Layout.addview (ImageView, p);
if (sname = null | | sname.equals ("")) {
Textview.settext ("-");
}else{
Textview.settext (sname);
sname = "";
Mhandler.post (Mscrolltobottom);
}
}
Private Runnable Mscrolltobottom = new Runnable ()
{
@Override
public void Run ()
{
int off = Layout.getmeasuredheight ()-namescroll.getheight ();
if (Off > 0)
{
Namescroll.scrollto (0, off);
}
}
};

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.