日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > Android >内容正文

Android

android 新的布局,Android新布局方式ConstraintLayout快速入门教程

發(fā)布時(shí)間:2023/12/3 Android 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android 新的布局,Android新布局方式ConstraintLayout快速入门教程 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

前言

在android開(kāi)發(fā)中,我們通常是手寫布局,很少會(huì)用拖動(dòng)來(lái)寫布局,雖然constraintlayout在i/o上以拖動(dòng)來(lái)展現(xiàn)了各種功能,我估計(jì)在以后開(kāi)發(fā)中,程序員還是習(xí)慣手?jǐn)]代碼。

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

那么

直接上手?jǐn)]了一下~~~

其實(shí)很簡(jiǎn)單

button1:app:layout_constraintbottom_totopof="@id/iv_head"

我們把這個(gè)屬性拆開(kāi)來(lái)看,constraintbottom指的本身的底部,即button1的頂部,totopof是指imageview的頂部,那么這句話的意思就是

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

翻譯一下就是button1的底部要和imageview的頂部對(duì)齊

button1 app:layout_constraintright_toleftof="@id/iv_head"

根據(jù)上面的規(guī)則我們就知道button1的右邊要和imageview的左邊對(duì)齊。

其實(shí)很簡(jiǎn)單就是說(shuō)兩個(gè)view的某個(gè)方位要對(duì)齊

沒(méi)了,就這么簡(jiǎn)單,其它屬性可以舉一反三,它比relativelayout控制起來(lái)更加得以就手。

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.

到此,你已經(jīng)掌握了一大半的constraintlayout知識(shí)點(diǎn)

還有其它的一些屬性

app:layout_constraintstart_toendof

意思就是button的開(kāi)始部分(從左往右看,開(kāi)始部分就是button的左邊)與imageview的右邊是對(duì)齊的。

app:layout_constraintstart_tostartof

這個(gè)就是說(shuō)button的左邊與imageview的左邊是對(duì)齊的

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

總結(jié)

以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來(lái)一定的幫助,如果有疑問(wèn)大家可以留言交流,謝謝大家對(duì)萬(wàn)仟網(wǎng)的支持。

創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)

總結(jié)

以上是生活随笔為你收集整理的android 新的布局,Android新布局方式ConstraintLayout快速入门教程的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。