国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android新布局方式ConstraintLayout快速入門教程

2019-10-23 18:27:48
字體:
來源:轉載
供稿:網友

前言

在Android開發中,我們通常是手寫布局,很少會用拖動來寫布局,雖然ConstraintLayout在I/O上以拖動來展現了各種功能,我估計在以后開發中,程序員還是習慣手擼代碼。

我自己試著拖著用了一下,用得不是很明白 ,而且用起來效果不是很好。

那么

直接上手擼了一下~~~

其實很簡單

constraintlayout布局,constraintlayout用法,constraintlayout屬性

constraintlayout布局,constraintlayout用法,constraintlayout屬性

Button1:app:layout_constraintBottom_toTopOf="@id/iv_head"

我們把這個屬性拆開來看,constraintBottom指的本身的底部,即Button1的頂部,toTopOf是指ImageView的頂部,那么這句話的意思就是

Aligns the bottom of the desired view to the top of another.(官方原文)

翻譯一下就是Button1的底部要和ImageView的頂部對齊

Button1 app:layout_constraintRight_toLeftOf="@id/iv_head"

根據上面的規則我們就知道Button1的右邊要和ImageView的左邊對齊。

其實很簡單就是說兩個View的某個方位要對齊

沒了,就這么簡單,其它屬性可以舉一反三,它比RelativeLayout控制起來更加得以就手。

  • layout_constraintTop_toTopOf?—?Align the top of the desired view to the top of another.
  • layout_constraintTop_toBottomOf?—?Align the top of the desired view to the bottom of another.
  • layout_constraintBottom_toTopOf?—?Align the bottom of the desired view to the top of another.
  • layout_constraintBottom_toBottomOf?—?Align the bottom of the desired view to the bottom of another.
  • layout_constraintLeft_toTopOf?—?Align the left of the desired view to the top of another.
  • layout_constraintLeft_toBottomOf?—?Align the left of the desired view to the bottom of another.
  • layout_constraintLeft_toLeftOf?—?Align the left of the desired view to the left of another.
  • layout_constraintLeft_toRightOf?—?Align the left of the desired view to the right of another.
  • layout_constraintRight_toTopOf?—?Align the right of the desired view to the top of another.
  • layout_constraintRight_toBottomOf?—?Align the right of the desired view to the bottom of another.
  • layout_constraintRight_toLeftOf?—?Align the right of the desired view to the left of another.
  • layout_constraintRight_toRightOf?—?Align the right of the desired view to the right of another.
  • If desired, attributes supporting start and end are also available in place of left and right alignment.

到此,你已經掌握了一大半的ConstraintLayout知識點

還有其它的一些屬性

app:layout_constraintStart_toEndOf

意思就是Button的開始部分(從左往右看,開始部分就是Button的左邊)與ImageView的右邊是對齊的。

app:layout_constraintStart_toStartOf

這個就是說Button的左邊與ImageView的左邊是對齊的

不知道為什么上面已經出的屬性能夠滿足布局需要了,為什么還要再出start和end的。

總結

以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作能帶來一定的幫助,如果有疑問大家可以留言交流,謝謝大家對VEVB武林網的支持。


注:相關教程知識閱讀請移步到Android開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 石台县| 三江| 永安市| 鞍山市| 兴安盟| 图木舒克市| 大名县| 虎林市| 丘北县| 云和县| 名山县| 天长市| 浙江省| 龙州县| 苏尼特右旗| 浑源县| 石景山区| 柘荣县| 双辽市| 民丰县| 通化市| 广昌县| 都安| 文登市| 阳泉市| 辽阳县| 百色市| 焉耆| 南城县| 青铜峡市| 河曲县| 尚志市| 肥西县| 花莲市| 阜康市| 冷水江市| 嘉善县| 崇阳县| 威远县| 西盟| 宜宾县|