View API with me (1) Add LinearLayout that you don't know, apilinearlayout

Source: Internet
Author: User

View API with me (1) Add LinearLayout that you don't know, apilinearlayout

The landlord's English proficiency is poor. If the translation is poor, please correct me more...


A Layout that arranges its children in a single column or a single row. The direction of * the row canbe set
Calling {@ link # setOrientation (int) setOrientation ()}. * You can also specify gravity, which specifies
Alignment of all the child elements by * calling {@ link # setGravity (int) setGravity ()} or specify that specific
Children * grow to fill up any remaining space in the layout by setting the <em> weight </em> member
{@ Link android. widget. LinearLayout. LayoutParams LinearLayout. LayoutParams}. * The default orientation is
Horizontal.
This is a layout that sorts subclasses in one column or row. You can call setOrientation () to set the Row Direction. You can also specify the direction
The method for alignment of all child elements is {@ link # setGravity (int) setGravity ()} or by setting the weight/weight (<em> </em>
Member) specify a specific subclass to fill in the remaining space layout {@ link android. widget. LinearLayout. LayoutParams LinearLayout.
LayoutParams }. The default direction is horizontal.
/**
* Don't show any dividers.
* No split line is displayed.
*/
Public static final int SHOW_DIVIDER_NONE = 0;
/**
* Show a divider at the beginning of the group.
* Display the split line before this view group
*/
Public static final int SHOW_DIVIDER_BEGINNING = 1;
/**
* Display the split line between each sub-view of the layout
* Show dividers between each item in the group.
*/
Public static final int SHOW_DIVIDER_MIDDLE = 2;
/**
* Display the split line at the end of the layout
* Show a divider at the end of the group.
*/
Public static final int SHOW_DIVIDER_END = 4;

First draw a line using shape. xml:
<? Xml version = "1.0" encoding = "UTF-8"?>
<Shape xmlns: android = "http://schemas.android.com/apk/res/android"
Android: layout_width = "match_parent" android: layout_height = "match_parent"
Android: shape = "rectangle">

<Size
Android: width = "@ dimen/fab_margin"
Android: height = "@ dimen/fab_margin"/>

<Solid android: color = "# ff00ff"/>

</Shape>

Sample Code 1 sets the split line to display at the very beginning of the subclass:
<LinearLayout
Android: layout_width = "fill_parent"
Android: gravity = "center"
Android: divider = "@ drawable/driver" <! -- Set the split line style -->
Android: showDividers = "beginning" <! -- Set the display mode of the split line -->
Android: layout_height = "fill_parent"
Android: orientation = "horizontal">
<Button
Android: id = "@ + id/bt1"
Android: layout_width = "120dp"
Android: layout_height = "60dp"
Android: text = "1"/>
<Button
Android: id = "@ + id/bt2"
Android: layout_width = "120dp"
Android: layout_height = "60dp"
Android: text = "2"/>
<Button
Android: id = "@ + id/bt3"
Android: layout_width = "120dp"
Android: layout_height = "60dp"
Android: text = "3"/>
</LinearLayout>
Example 2 shows the split line between each sub-view of the layout:
<LinearLayout
Android: layout_width = "fill_parent"
Android: gravity = "center"
Android: divider = "@ drawable/driver"
Android: showDividers = "end"
Android: layout_height = "fill_parent"
Android: orientation = "horizontal">
<Button
Android: id = "@ + id/bt1"
Android: layout_width = "120dp"
Android: layout_height = "60dp"
Android: text = "1"/>
<Button
Android: id = "@ + id/bt2"
Android: layout_width = "120dp"
Android: layout_height = "60dp"
Android: text = "2"/>
<Button
Android: id = "@ + id/bt3"
Android: layout_width = "120dp"
Android: layout_height = "60dp"
Android: text = "3"/>
</LinearLayout>
Example 3 * display the split line at the end of the layout:
<LinearLayout
Android: layout_width = "fill_parent"
Android: gravity = "center"
Android: divider = "@ drawable/driver" <! -- Set the split line style -->
Android: showDividers = "middle" <! -- Set the display mode of the split line -->
Android: layout_height = "fill_parent"
Android: orientation = "horizontal">
<Button
Android: id = "@ + id/bt1"
Android: layout_width = "120dp"
Android: layout_height = "60dp"
Android: text = "1"/>
<Button
Android: id = "@ + id/bt2"
Android: layout_width = "120dp"
Android: layout_height = "60dp"
Android: text = "2"/>
<Button
Android: id = "@ + id/bt3"
Android: layout_width = "120dp"
Android: layout_height = "60dp"
Android: text = "3"/>
</LinearLayout>
Example 4 * display the split line in the middle of the layout:
<LinearLayout
Android: layout_width = "fill_parent"
Android: gravity = "center"
Android: divider = "@ drawable/driver" <! -- Set the split line style -->
Android: showDividers = "middle | beginning | end" <! -- Set the display mode of the split line -->
Android: layout_height = "fill_parent"
Android: orientation = "horizontal">
<Button
Android: id = "@ + id/bt1"
Android: layout_width = "120dp"
Android: layout_height = "60dp"
Android: text = "1"/>
<Button
Android: id = "@ + id/bt2"
Android: layout_width = "120dp"
Android: layout_height = "60dp"
Android: text = "2"/>
<Button
Android: id = "@ + id/bt3"
Android: layout_width = "120dp"
Android: layout_height = "60dp"
Android: text = "3"/>
</LinearLayout>

 

/**
* Set padding displayed on both ends of dividers.
*
* @ Param padding Padding value in pixels that will be applied to each end
*
* @ See # setShowDividers (int)
* @ See # setDividerDrawable (Drawable)
* @ See # getDividerPadding ()
*/

/**
* Set the padding to display the two ends of the splitter.
*
* @ Param the padding value will use pixels as the unit
*
* @ See # setShowDividers (int)
* @ See # setDividerDrawable (movable)
* @ See # getDividerPadding ()
*/
Public void setDividerPadding (int padding ){
MDividerPadding = padding;
}
Android: dividerPadding = "12dp"
3,
/**
* Whether the children of this layout are baseline aligned. Only applicable
* If {@ link # mOrientation} is horizontal.
*/
@ ViewDebug. ExportedProperty (category = "layout ")
Private boolean mBaselineAligned = true;
Whether the child view of this layout is baseline aligned. Only applicable to horizontal layout-Note: The baseline is in the middle
For xml code, you only need to add attributes in the LinearLayout layout:
Android: baselineAligned = "true"
* {@ Link # mOrientation}

If this layout is part of another layout that is baseline aligned,
* Use the child at this index as the baseline.
*
* Note: this is orthogonal to {@ link # mBaselineAligned}, which is concerned
* With whether the children of this layout are baseline aligned.
@ ViewDebug. ExportedProperty (category = "layout ")
*/
@ ViewDebug. ExportedProperty (category = "layout ")
Private int mBaselineAlignedChildIndex =-1;
Private int mBaselineAlignedChildIndex =-1;
If this layout is part of another baseline alignment layout,
* Use the subview as the benchmark in this index.
*
* Note: This is orthogonal to {@ link # mBaselineAligned}, Which is worried.
* Whether the child view of the layout is baseline aligned.
Android: baselineAlignedChildIndex = "-1"

/**
* When true, all children with a weight will be considered having
* The minimum size of the largest child. If false, all children are
* Measured normally.
*
* @ Return True to measure children with a weight using the minimum
* Size of the largest child, false otherwise.
*
* @ Attr ref android. R. styleable # LinearLayout_measureWithLargestChild
*/
Public boolean isMeasureWithLargestChildEnabled (){
Return mUseLargestChild;
}

/**
When it is true, all subclasses with the same weight/weight are considered to be the minimum weight of the largest subclass.
If the measurement is false for all sub-classes, and the time weight/proportion is the same

android:measureWithLargestChild="true"

Starting from tonight, I will translate a little bit every night... Stick to Uncle

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.