最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時間:2017年05月26日 11:19:32   作者:Android傳習錄  
谷歌在2016年的IO大會上推出的一種新的布局方式—-ConstraintLayout,這局是一種約束型的布局方式,下面這篇文章主要給大家介紹了Android中新布局方式ConstraintLayout的相關資料,需要的朋友可以參考借鑒,下面來一起看看吧。

前言

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

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

那么

直接上手擼了一下~~~

其實很簡單

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"

根據(jù)上面的規(guī)則我們就知道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的。

總結

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

相關文章

  • JetpackCompose Navigation導航實現(xiàn)流程

    JetpackCompose Navigation導航實現(xiàn)流程

    Navigation是Jetpack用于Android導航的組件,作用是處理頁面跳轉,以及頁面跳轉過程中的交互。使用Navigation,你就需要為每個頁面設定一條唯一路徑,它是一個String常量,形式是DeepLink的樣子,從一個頁面跳轉到另一個頁面,它通過輸入目的地的路徑進行轉跳
    2023-01-01
  • Android仿騰訊QQ實現(xiàn)滑動刪除 附源碼下載

    Android仿騰訊QQ實現(xiàn)滑動刪除 附源碼下載

    仿騰訊QQ滑動刪除操作,這篇文章主要為大家詳細介紹了ListView滑動刪除的具體操作方法,感興趣的小伙伴們可以參考一下
    2016-07-07
  • Android桌面插件App Widget用法分析

    Android桌面插件App Widget用法分析

    這篇文章主要介紹了Android桌面插件App Widget用法,結合實例形式分析了桌面插件App Widget的功能、布局、創(chuàng)建及使用方法,需要的朋友可以參考下
    2016-08-08
  • Android實現(xiàn)屏幕旋轉四個方向準確監(jiān)聽

    Android實現(xiàn)屏幕旋轉四個方向準確監(jiān)聽

    這篇文章主要為大家詳細介紹了Android實現(xiàn)屏幕旋轉四個方向準確監(jiān)聽,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-07-07
  • Android 異步任務和消息機制面試題分析

    Android 異步任務和消息機制面試題分析

    這篇文章主要為大家介紹了Android 異步任務和消息機制面試題分析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2023-07-07
  • Android實現(xiàn)長圖展開與收起效果

    Android實現(xiàn)長圖展開與收起效果

    這篇文章主要為大家詳細介紹了Android實現(xiàn)長圖展開與收起效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-09-09
  • Android 使用版本控制工具時添加忽略文件的方式(詳解)

    Android 使用版本控制工具時添加忽略文件的方式(詳解)

    下面小編就為大家?guī)硪黄狝ndroid 使用版本控制工具時添加忽略文件的方式(詳解)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-01-01
  • Android Studio中通過CMake使用NDK并編譯自定義庫和添加預編譯庫

    Android Studio中通過CMake使用NDK并編譯自定義庫和添加預編譯庫

    這篇文章是基于Android Studio 3.01版本的,NDK是R16。本文重點給大家介紹Android Studio中通過CMake使用NDK并編譯自定義庫和添加預編譯庫的相關知識,感興趣的朋友一起看看吧
    2018-01-01
  • Android編程創(chuàng)建與解析xml的常用方法詳解

    Android編程創(chuàng)建與解析xml的常用方法詳解

    這篇文章主要介紹了Android編程創(chuàng)建與解析xml的常用方法,結合具體實例形式較為詳細的分析了Android操作xml文件的步驟、實現(xiàn)技巧與相關注意事項,需要的朋友可以參考下
    2017-05-05
  • Android實現(xiàn)圓圈倒計時

    Android實現(xiàn)圓圈倒計時

    這篇文章主要為大家詳細介紹了Android實現(xiàn)圓圈倒計時,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-08-08

最新評論

邳州市| 长岭县| 青州市| 北宁市| 冕宁县| 凌云县| 汉阴县| 天长市| 外汇| 外汇| 南川市| 陈巴尔虎旗| 辉县市| 河津市| 清流县| 金秀| 电白县| 台北市| 仁怀市| 城口县| 日土县| 辽源市| 郎溪县| 永德县| 苗栗县| 阿坝县| 潮安县| 岳阳市| 安庆市| 霍州市| 阿巴嘎旗| 闻喜县| 奎屯市| 西吉县| 龙州县| 澄江县| 托克托县| 德阳市| 太和县| 屏东市| 兰考县|