Solve the problem that edittext can't fill full screen and edittext the attributes you should know

Source: Internet
Author: User

In general, we want to achieve the effect of one is very simple:
two edittext to take care of one:

but we want the second edittext to fill the rest of the space. such as two
Two:
Solve:

The Android:fillviewport in ScrollView is set to true using the ScrollView nested linearlayout.

Analysis:

When the elements in the ScrollView want to fill ScrollView, using "fill_parent" is not useful and must be set to ScrollView: Android:fillviewport= "true".

When ScrollView does not fillveewport= "true", the elements inside (such as linearlayout) are calculated according to the wrap_content (whether or not it is set to "Fill_parent"), And if the elements of the LinearLayout set fill_parent, then it is no use, because the linearlayout depends on the elements inside, and the elements in the linearlayout, such contradictions. So the inside element is set to Fill_ The parent will also be counted as wrap_content.


Source: http://blog.sina.com.cn/s/blog_6cf2ea6a0102v61f.html


The code follows, commenting on the commonly used EditText properties:
  
 
  1. <ScrollView
  2. android:layout_width="match_parent"
  3. android:layout_height="0dp"
  4. android:layout_weight="1"
  5. android:fillViewport="true">Key points ********
  6. <LinearLayout
  7. android:layout_width="match_parent"
  8. android:layout_height="match_parent"
  9. android:orientation="vertical">
  10. <EditText
  11. android:id="@+id/edit_title"
  12. android:layout_width="match_parent"
  13. android:layout_height="wrap_content"
  14. android:layout_gravity="center|left"
  15. android:layout_marginLeft="16dp"
  16. android:layout_marginRight="16dp"
  17. android:background="@null"Control background, not here, refers to transparent
  18. android:ellipsize="end"Auto-hide trailing overflow data, typically used for long lines of text when the line cannot be displayed all
  19. android:hint="添加标题"
  20. android:paddingBottom="10dp"
  21. android:paddingTop="10dp"
  22. android:singleLine="true"Force input on a single line
  23. android:textColorHint="#bfbfbf" />
  24. <LinearLayout
  25. android:layout_width="match_parent"
  26. android:layout_height="2dp"
  27. android:layout_marginLeft="10dp"
  28. android:layout_marginRight="10dp"
  29. android:background="@drawable/dotted_line"
  30. android:layerType="software" />
  31. <RelativeLayout
  32. android:layout_width="match_parent"
  33. android:layout_height="0dp"
  34. android:layout_weight="1">
  35. <EditText
  36. android:id="@+id/edit_content"
  37. android:layout_width="match_parent"
  38. android:layout_height="match_parent"
  39. android:layout_marginLeft="16dp"
  40. android:layout_marginRight="16dp"
  41. android:layout_marginTop="16dp"
  42. android:gravity="left|top" Cursor in upper left corner when input
  43. android:hint="内容"
  44. android:lineSpacingExtra="4.6dp"Set line spacing
  45. android:scrollbars="vertical"Set scroll bar display
  46. android:textColorHint="#bfbfbf"
  47. android:textSize="16sp" />
  48. </RelativeLayout>
  49. <!--
  50. android:background="@null"Remove the EditView border
  51. android:inputType="textMultiLine"can display multiple lines
  52. android:minLines="6"Set the minimum number of lines of text
  53. -->
  54. </LinearLayout>
  55. </ScrollView>






From for notes (Wiz)

Solve the problem that edittext can't fill full screen and edittext the attributes you should know

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.