ConstraintLayout (約束布局)屬性詳情


本文部分內容來自於網絡,點擊瀏覽原文

app:layout_constraintLeft_toLeftOf

//Constrains the left side of a child to the left side of a target child (contains the target child id).

表示此控件的左邊框與某個控件的左邊框對齊或者在其右邊


視圖1

 


代碼1

 

app:layout_constraintLeft_toRightOf

//Constrains the left side of a child to the right side of a target child (contains the target child id).

表示此控件的左邊框與某個控件的右邊框對齊或者在其右邊


視圖2

 

app:layout_constraintRight_toLeftOf

//Constrains the right side of a child to the left side of a target child (contains the target child id).

表示此控件的右邊框與某個控件的左邊框對齊或在其左邊


視圖3

 

app:layout_constraintRight_toRightOf

//Constrains the right side of a child to the right side of a target child (contains the target child id).

表示此控件的右邊框與某個控件的右邊框對齊或在其左邊


視圖4

 

app:layout_constraintTop_toTopOf

//Constrains the top side of a child to the top side of a target child (contains the target child id).

表示此控件的頂部邊框與某個控件的頂部邊框水平對齊或在其下邊


視圖5

 

app:layout_constraintTop_toBottomOf

//Constrains the top side of a child to the bottom side of a target child (contains the target child id).

表示此控件的頂部邊框與某個控件的底部邊框水平對齊或在其下邊


視圖6

 

app:layout_constraintBottom_toTopOf

//Constrains the bottom side of a child to the top side of a target child (contains the target child id).

表示此控件的底部邊框與某個控件的頂部邊框水平對齊或其上邊


視圖7

 

app:layout_constraintBottom_toBottomOf

//Constrains the bottom side of a child to the bottom side of a target child (contains the target child id).

表示此控件的底部邊框與某個控件的底部邊框水平對齊或其上邊


視圖8

 

app:layout_constraintBaseline_toBaselineOf

//Constrains the baseline of a child to the baseline of a target child (contains the target child id).

表示此控件與某個控件水平對齊


視圖9

 


代碼2

 

app:layout_editor_absoluteX

//The design time location of the left side of the child.

表示此控件在布局中X軸的絕對坐標點。如圖代碼3


代碼3

 

app:layout_editor_absoluteY

//The design time location of the right side of the child.

表示此控件在布局中Y軸的絕對坐標點。如圖代碼3

app:layout_constraintGuide_begin

//The distance of child (guideline) to the top or left edge of its parent.

表示在布局中引導線距頂部或左邊框的距離(如:20dp表示距頂部或者左邊框20dp)


視圖10

 

 


代碼10

 

app:layout_constraintGuide_end

//The distance of child (guideline) to the top or left edge of its parent.

表示在布局中引導線距底部的距離(如:10dp表示距頂部10dp)

app:layout_constraintGuide_percent

//The ratio of the distance to the parent's sides

表示在整個布局中引導線距離左邊框的百分百(如:app:layout_constraintGuide_percent="0.5"表示距離左邊框50%的位置)


視圖11

 

 


代碼11

 

app:layout_constraintStart_toEndOf

//Constrains the start side of a child to the end side of a target child (contains the target child id).

表示此控件的左邊界在某個控件右邊界的右邊,及表示此控件在某個控件的右邊


視圖12

 

app:layout_constraintStart_toStartOf

//Constrains the start side of a child to the start side of a target child (contains the target child id).

表示此控件的左邊界與某個控件的左邊界在同一垂直線上


視圖13

 

app:layout_constraintEnd_toStartOf

//Constrains the end side of a child to the start side of a target child (contains the target child id).

表示此控件的右邊界與某個控件的左邊界在同一垂直線上


視圖14

 

app:layout_constraintEnd_toEndOf

//Constrains the end side of a child to the end side of a target child (contains the target child id).

表示此控件的右邊界與某個控件的右邊界對齊


視圖15

 

app:layout_constraintHorizontal_bias

//The ratio between two connections when the left and right (or start and end) sides are constrained.

表示此控件在布局中的水平方向上的偏移百分百。如視圖16,代碼16


視圖16

 

app:layout_constraintVertical_bias

//The ratio between two connections when the top and bottom sides are constrained.

表示此控件在布局中的的垂直方向上的偏移百分百。如視圖16,代碼16


代碼16

 

app:layout_constraintDimensionRatio

//The child's side to constrain using dimensRatio.

表示兩個控件的縱橫比,而使用則需要把寬(layout_width)或者高(layout_height)設置為0dp,根據另一個屬性和比例, 計算當前屬性, 如兩個圖片控件的顯示大小,app:layout_constraintDimensionRatio="4:3";

 


視圖13

 

app:layout_goneMarginLeft

//The left margin to use when the target is gone.

app:layout_goneMarginTop

//The top margin to use when the target is gone.

app:layout_goneMarginRight

//The right margin to use when the target is gone

app:layout_goneMarginBottom

//The bottom margin to use when the target is gone.

app:layout_goneMarginStart

//The start margin to use when the target is gone.

app:layout_goneMarginEnd

//The end margin to use when the target is gone.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM