Android layout attributes

Source: Internet
Author: User
Attribute Description
Android: Background Layout background
Android: layout_margintop Distance from the previous layout
Android: gravity The text position in the layout, for example, center
Android: layout_gravity The entire layout, such as vertical center.
Android: layout_alignparenttop Whether the layout is on the top, with the left, right, and bottom
Android: Text Text to be displayed in the text layout, such as textview and button
Android: layout_aligntop = "@ ID/OK" Set the height of the component with the ID as OK

Linearlayout has two very similar attributes: Android: gravity and Android: layout_gravity. The difference is that Android: gravity is used to set the alignment of the view component, while Android: layout_gravity is used to set the alignment of the container component.

For example, you can set Android: gravity = "center" to center the text in edittext in the edittext component, and set android of edittext: layout_gravity = "right" to center the edittext component in linearlayout.

 

Padding margin is the meaning of margins. The key issue is to understand what the margins are.

Padding is the margin of the control content relative to the control edge.

Margin is the margin of the control edge relative to the parent space.

Do you think of the difference between gravity and layout_gravity we mentioned earlier.

 

 

 

 

  1. Android: Orientation ="Vertical"Vertical Alignment
  2. Android: Orientation ="Horizontal"Horizontal Alignment
  3. Android: layout_width ="Fill_parent"Define the current view on the screen
  4. The consumable width. fill_parent fills the screen.
  5. Android: layout_height ="Wrap_content": Different text fields
  6. Change the width or height of the view. It means setting the box degree or height automatically.
  7. Layout_weight is used to assign importance values to multiple views in a linear layout.
  8. All views have a layout_weight value. The default value is 0, indicating that the value must be displayed.
  9. The size of the view occupies the size of the blank screen. If a value greater than zero is assigned, the parent
  10. The available space in the image is separated. The split size depends on the layout_weight of each view.
  11. Value and the overall layout_weight value of the value in the current screen layout and
  12. The percentage of the layout_weight value is determined.
  13. For example, we have a text label and two text editing elements in the horizontal direction.
  14. The text label does not specify the layout_weight value, so it occupies the minimum space required.
  15. If the layout_weight value of each of the two text editing elements is set1, The two are equally divided.
  16. The remaining width of the layout in the parent view (because we declare that the importance of the two is equal ). If two
  17. The first value of layout_weight in the text editing element is set1And the second one is2,
  18. Then 2/3 of the remaining space is allocated to the first space, and 1/3 to the second Space (the smaller the value, the more important
  19. Higher Degree ).

 

 

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.