For android textview and edittext, the interface is choppy and textviewedittext

Source: Internet
Author: User

For android textview and edittext, the interface is choppy and textviewedittext

When we usually use textview and edittextview, we always write the corresponding xml at will, but if you do not pay attention to sliding and other effects on your interface, you may find that your interface is sometimes very stuck. We often cannot figure out the specific reason for the card and where it is stuck, and clearly there is no time-consuming operation, there is one more sentence on the interface. The settex function of textview cannot be card. Sometimes we may doubt that the android mechanism is not as good as Apple's. In fact, the specific reason is that we do not know enough about the control.

When scrollview or listview controls exist in an interface, we need to slide the interface, and sometimes the sliding interface has the corresponding textview to explain, but when sliding, we find that the interface is particularly stuck. In this case, make sure that the width and height of the textview are set to wrapcontent in your xml file. In this case, set it to fillparent. Of course, sometimes fillparent is not easy to use, because if the length and width of the parent view of your textview are also a variable value, it may also cause freezing.

Why is choppy after wrapcontent is used. After thinking, I found that when sliding, The listview or scrollview is actually re-painting its sub-view. In this case, textview is set when sliding, for example, textview is used to modify the content. At this time, because the length of the content set in textview has changed, it may cause a conflict with the re-painting of the parent view and the calculation length and width. Therefore, to avoid such conflicts, the length and width of textview must be computed by the parent view. Therefore, if you set it to fillparent or you fix the length and width, the interface may be stuck when the content of textview is set. In short, when you cannot find the root cause of choppy, check whether the length and width of the parent view have been affected by the Child view.

In fact, there are a lot of questions on the Internet about the slow sliding of listview. In fact, the summary is not very complete. Most of them are statements about setting listview to fillparent. Many say that getview is repeatedly called, it also has something to do with this. In fact, many of these are due to the fact that the length and width of textview are not a fixed value or cannot be tested. If you write them into a value, you will find that the interface is smooth.


In android, when TextView is displayed on the interface, I want to add two buttons above the keyboard display. One is OK and the other is canceled.

The Code is as follows:
You can just paste it into and run it. You can just write the activity and remember to configure manifest ~~~
<? Xml version = "1.0" encoding = "UTF-8"?>
<RelativeLayout xmlns: android = "schemas.android.com/apk/res/android"
Android: layout_width = "fill_parent" android: layout_height = "fill_parent">
<EditText android: id = "@ + id/et" android: layout_height = "wrap_content"
Android: layout_width = "fill_parent" android: layout_above = "@ id/add"/>
<Button android: text = "OK" android: id = "@ + id/add"
Android: layout_alignParentBottom = "true" android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"/>
<Button android: text = "cancle" android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_alignParentBottom = "true"
Android: layout_toRightOf = "@ id/add"/>
</RelativeLayout>

How to obtain edittext content in Android programming and display it in textview

Put this sentence EditText t1 = (EditText) findViewById (R. id. editText1 );
Public void onClick (View v ){

}); Inside

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.