内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

android中怎么使用ConstraintLayout布局

這期內(nèi)容當(dāng)中小編將會(huì)給大家?guī)?lái)有關(guān)android中怎么使用ConstraintLayout 布局,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。

創(chuàng)新互聯(lián)是一家集網(wǎng)站建設(shè),蚌埠企業(yè)網(wǎng)站建設(shè),蚌埠品牌網(wǎng)站建設(shè),網(wǎng)站定制,蚌埠網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營(yíng)銷,網(wǎng)絡(luò)優(yōu)化,蚌埠網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競(jìng)爭(zhēng)力。可充分滿足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶成長(zhǎng)自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。

1,要想使用ConstraintLayout需要在app的build.gradle里面引入:

compile 'com.android.support.constraint:constraint-layout:1.0.2'

2,首先看一個(gè)簡(jiǎn)單的xml和圖片效果:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.app.qichun.hellowrod.MainActivity">

<TextView
  android:id="@+id/tv1"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="Hello World!"
  app:layout_constraintTop_toTopOf="parent"
 />
<TextView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="第二個(gè)控件"
  app:layout_constraintLeft_toLeftOf="parent"
  app:layout_constraintTop_toBottomOf="@+id/tv1"
  />
<TextView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="第三個(gè)控件"
  app:layout_constraintBottom_toBottomOf="parent"
  />
<TextView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="第四個(gè)控件"
  app:layout_constraintLeft_toRightOf="@+id/tv1"
  android:layout_marginLeft="10dp"
  />
 </android.support.constraint.ConstraintLayout>

android中怎么使用ConstraintLayout 布局

各位看客官不難看出,xml中四個(gè)簡(jiǎn)單的Textview分布位置,以id為tv的第一個(gè)控件為基準(zhǔn),第二個(gè)控件在第一個(gè)控件的下方,且都在整個(gè)布局的左邊;第三個(gè)控件在整個(gè)父布局的左下方;第四個(gè)控件在第一個(gè)控件的右邊。

仔細(xì)觀察,每個(gè)Textview都有類似的屬性:

比如第一個(gè)控件的:

app:layout_constraintTop_toTopOf="parent"

第二個(gè)控件的

app:layout_constraintTop_toBottomOf="@+id/tv1"

字面意思就是:

該控件的某個(gè)邊和某個(gè)控件的某個(gè)邊對(duì)齊。

比如,第一個(gè)控件是該控件的上部和父布局的上部對(duì)齊,自然就使得第一個(gè)控件處于左上方;第二個(gè)控件的頂部和第一個(gè)控件即id=tv1的控件的底部對(duì)齊,自然第二個(gè) 控件就會(huì)位于第一個(gè)控件的正下方。其他舉一反三即可。
現(xiàn)在我們規(guī)定一個(gè)布局再次試驗(yàn)一下,搞個(gè)最常見(jiàn)的布局。

android中怎么使用ConstraintLayout 布局

代碼如下:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.app.qichun.hellowrod.MainActivity">

<TextView
  android:id="@+id/tv1"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="任務(wù)"
 <!-- 該控件的頂部和父布局的頂部對(duì)齊 !-->
  app:layout_constraintTop_toTopOf="parent"
 />
<TextView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="已完成"
  <!-- 該控件的右邊和父布局的左邊對(duì)齊 !-->
  app:layout_constraintRight_toLeftOf="parent"
  android:layout_marginRight="10dp"
  />
<TextView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="劉剛"
 <!-- 該控件的頂部和tv1的底部對(duì)其齊!-->
  app:layout_constraintTop_toBottomOf="@+id/tv1"
  />
<TextView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="完成時(shí)間"
  <!-- 該控件的右邊和父布局的左邊對(duì)齊 !-->
  app:layout_constraintRight_toLeftOf="parent"
 <!-- 該控件的頂部和tv1的底部對(duì)齊 !-->
  app:layout_constraintTop_toBottomOf="@+id/tv1"
  android:layout_marginRight="10dp"
  />
</android.support.constraint.ConstraintLayout>

上述就是小編為大家分享的android中怎么使用ConstraintLayout 布局了,如果剛好有類似的疑惑,不妨參照上述分析進(jìn)行理解。如果想知道更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

新聞標(biāo)題:android中怎么使用ConstraintLayout布局
新聞來(lái)源:http://www.rwnh.cn/article42/jgpehc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供靜態(tài)網(wǎng)站、做網(wǎng)站服務(wù)器托管、面包屑導(dǎo)航、微信小程序、定制網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

搜索引擎優(yōu)化
丰宁| 安仁县| 永定县| 蒙城县| 东阿县| 肇州县| 罗定市| 正定县| 临夏市| 轮台县| 德令哈市| 惠东县| 竹溪县| 郎溪县| 鄂托克旗| 林口县| 额尔古纳市| 西乌珠穆沁旗| 大城县| 祁门县| 宽甸| 昆山市| 安泽县| 黑河市| 漳浦县| 罗江县| 满城县| 桑日县| 桃园县| 漯河市| 泰兴市| 新沂市| 松阳县| 胶南市| 当雄县| 锦屏县| 望都县| 普兰县| 尼木县| 阿荣旗| 仙桃市|