Android布局小記
布局系列通用屬性
1.android:layout_width="match_parent"
2.android:layout_height="match_parent"
3.android:gravity="" 設(shè)置被包裹的空間的位置
4.android:visibility= 顯示 visible 不顯示虐沥,但占空間 invisible 隱藏 gone
5.layout_gravity 設(shè)置控件相對于父控件的位置
還有些不怎么很常用的熊经,用的時(shí)候再查好了
LinearLayout (線性布局)
LinearLayout 常用在布局嵌套的情況下,控件在布局中可以按照水平或者垂直排列欲险。最好不要設(shè)置成wrap_content镐依,這樣會導(dǎo)致二次測量(后面源碼中有解釋)。
特點(diǎn):控件一定不會出現(xiàn)重疊的情況
基本屬性:
1.android:orientation 設(shè)置布局的排列方式天试,水平或者垂直
2.android:layout_weight="1"權(quán)值設(shè)置槐壳,某個(gè)控件占布局的多少(linearLayout中控件屬性)
注:如果android:orientation設(shè)置為horizontal? 那么在控件中android:layout_gravity="center_horizontal"無效。(因?yàn)椴季值呐帕蟹绞胶瓦@種設(shè)置時(shí)沖突的喜每,舉個(gè)例子务唐,這就像父母讓孩子上學(xué),孩子想去游樂園带兜,結(jié)果自然是聽父母的)?
案例一枫笛,利用LinearLayout實(shí)現(xiàn)APP中頭布局的效果
<LinearLayout
? ? ? android:layout_width="match_parent"
? ? ? android:layout_height="wrap_content"
? ? ? android:background="#ccc"
? ? ? android:orientation="horizontal">
? ? ? <TextView
? ? ? ? ? android:layout_marginLeft="10dp"
? ? ? ? ? android:layout_gravity="center_vertical"
? ? ? ? ? android:layout_width="wrap_content"
? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? android:text="title測試"/>
? ? ? <ImageView
? ? ? ? ? android:layout_width="30dp"
? ? ? ? ? android:layout_height="30dp"
? ? ? ? ? android:layout_marginLeft="250dp"
? ? ? ? ? android:src="@drawable/ic_launcher_foreground" />
? ? ? <ImageView
? ? ? ? ? android:layout_marginLeft="10dp"
? ? ? ? ? android:layout_width="30dp"
? ? ? ? ? android:layout_height="30dp"
? ? ? ? ? android:src="@drawable/ic_launcher_foreground" />
? </LinearLayout>
實(shí)現(xiàn)效果:
android:layout_marginLeft="10dp" 這個(gè)屬性是根據(jù)上一個(gè)控件的位置計(jì)算偏移
案例二:實(shí)現(xiàn)每個(gè)在布局中均分的效果
<LinearLayout
? ? ? android:layout_width="match_parent"
? ? ? android:layout_height="wrap_content"
? ? ? android:background="#ccc"
? ? ? android:orientation="horizontal">
? ? ? <TextView
? ? ? ? ?? android:gravity="center"
? ? ? ? ? android:layout_gravity="center_vertical"
? ? ? ? ? android:layout_width="0dp"
? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? android:layout_weight="1"
? ? ? ? ? android:text="title測試"/>
?
? ? ? <ImageView
? ? ? ? ? android:layout_height="30dp"
? ? ? ? ? android:layout_width="0dp"
? ? ? ? ? android:layout_weight="1"
? ? ? ? ? android:src="@drawable/ic_launcher_foreground" />
? ? ? <ImageView
? ? ? ? ? android:layout_width="0dp"
? ? ? ? ? android:layout_height="30dp"
? ? ? ? ? android:layout_weight="1"
? ? ? ? ? android:src="@drawable/ic_launcher_foreground" />
? </LinearLayout>
實(shí)現(xiàn)效果:
結(jié)論:? 首先明確一個(gè)概念,LinearLayout常在布局嵌套的外層使用刚照,在上面的例子也能看出刑巧,在LinearLayout直接放控件實(shí)在寫起來麻煩,官方也不贊同這么做无畔。
LinearLayout源碼簡單分析:
對于一個(gè)ViewGroup繪制必走的三個(gè)流程啊楚,onMeasure,onLayout檩互,onDraw特幔,順著看一下源碼是怎么寫的
public class LinearLayout extends ViewGroup {
?? /** @hide */
?? @IntDef({HORIZONTAL, VERTICAL})
?? @Retention(RetentionPolicy.SOURCE)
? ? ......
首先LinearLayout是繼承ViewGroup的
然后是出現(xiàn)的是四個(gè)構(gòu)造函數(shù)
簡單記一下:
第一個(gè)構(gòu)造函數(shù):只有在代碼中new的時(shí)候調(diào)用,官網(wǎng)解釋也很簡單
第二個(gè)構(gòu)造函數(shù):在xml中使用的時(shí)候調(diào)用闸昨,最常用的一種
第三個(gè)構(gòu)造函數(shù):在xml中蚯斯,LinearLayout布局中控件有設(shè)定style屬性薄风,就開始調(diào)用第三個(gè)構(gòu)造函數(shù),并有得到結(jié)論【結(jié)論1】:優(yōu)先級xml定義>style>theme(本行結(jié)論參考http://www.reibang.com/p/7389287c04bb)
第四個(gè)構(gòu)造函數(shù):我試了幾種方案都沒有調(diào)用拍嵌,但是上面鏈接也寫了那種情況遭赂。
第一步: onMeasure方法
@Override
?? protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
? ? ?? if (mOrientation == VERTICAL) {
? ? ? ? ?? measureVertical(widthMeasureSpec, heightMeasureSpec);
? ? ?? } else {
? ? ? ? ?? measureHorizontal(widthMeasureSpec, heightMeasureSpec);
? ? ?? }
?? }
判斷了一下LinearLayout的orientation屬性,然后根據(jù)orientation寫了兩個(gè)方法横辆,追一個(gè)看看
-------------------------------measureVertical()方法干了什么------------------------------------
// See how tall everyone is. Also remember max width.
? ? ?? for (int i = 0; i < count; ++i) {
? ? ? ? ?? final View child = getVirtualChildAt(i);
? ? ? ? ?? .......
? //根據(jù)注釋撇他,這一塊是看一下每一個(gè)控件的高,然后記住最大的寬度狈蚤。然后獲取權(quán)重等等
?? // 測量模式有三種:
? ? // * UNSPECIFIED:父控件對子控件無約束
? ? // * Exactly:父控件對子控件強(qiáng)約束困肩,子控件永遠(yuǎn)在父控件邊界內(nèi),越界則裁剪脆侮。如果要記憶的話锌畸,可以記憶為有對應(yīng)的具體數(shù)值或者是Match_parent
? ? // * AT_Most:子控件為wrap_content的時(shí)候,測量值為AT_MOST靖避。
?? //這里獲取總權(quán)重潭枣,當(dāng)我們設(shè)置了總權(quán)重則用我們設(shè)置的權(quán)重值,如果沒有設(shè)置幻捏,則用子控件權(quán)重相加的和
? ? 從這里推出**結(jié)論** linearLayout的onMeasure進(jìn)行了兩次測量
結(jié)論 :? ? LinearLayout是wrap_content盆犁,或者mode為UNSPECIFIED,計(jì)算新的mTotalLength篡九,因?yàn)檫@時(shí)候所有子控件都是用最大控件的最小值
注:mode為UNSPECIFIED的情況并不常見谐岁,LinearLayout 設(shè)置的是橫向的 但是你的子布局全是充滿屏幕 就這點(diǎn)感覺就均分不了的,可能會出現(xiàn)這種情況榛臼。
第二步:onMeasure方法翰铡。
protected void onLayout(boolean changed, int l, int t, int r, int b) {
? ? ?? if (mOrientation == VERTICAL) {
? ? ? ? ?? layoutVertical(l, t, r, b);
? ? ?? } else {
? ? ? ? ?? layoutHorizontal(l, t, r, b);
? ? ?? }
?? }
這一步也有兩個(gè)方法
第三步:繪制onDraw()
RelativeLayout(相對布局)
相對布局以前是as中默認(rèn)布局,每個(gè)控件都默認(rèn)在左上角讽坏,需要手動(dòng)設(shè)置控件的之間的位置關(guān)系
居中屬性:
android:layout_centerHrizontal 水平居中
android:layout_centerVertical 垂直居中
android:layout_centerInparent 相對于父控件完全居中
位置調(diào)整屬性:
android:layout_alignParentBottom 貼緊父控件的下邊緣
android:layout_alignParentLeft 貼緊父控件的左邊緣
android:layout_alignParentRight 貼緊父控件的右邊緣
android:layout_alignParentTop 貼緊父控件的上邊緣
android:layout_below 在某控件下方
adroid:layout_above 在某控件上方
android:layout_toLeftOf 在某控件的左邊
android:layout_toRightOf 在某控件的右邊
android:layout_alignTop 本控件的上邊緣和某控件的上邊緣對齊
android:layout_alignLeft 本控件的左邊緣和某控件的左邊緣對齊
android:layout_alignBottom 本控件的下邊緣和某控件的下控件對齊
android:layout_alignRight 本控件的右邊緣和某控件的有邊緣對齊
案例一:同理實(shí)現(xiàn)一個(gè)title布局
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
?? android:layout_width="match_parent"
?? android:layout_height="50dp"
?? android:background="#ccc">
?
?? <TextView
? ? ?? android:layout_width="wrap_content"
? ? ?? android:layout_height="wrap_content"
? ? ?? android:layout_centerVertical="true"
? ? ?? android:layout_marginLeft="15dp"
? ? ?? android:text="測試title" />
?
?? <ImageView
? ? ?? android:id="@+id/iv_test1"
? ? ?? android:layout_width="30dp"
? ? ?? android:layout_height="30dp"
? ? ?? android:layout_alignParentRight="true"
? ? ?? android:layout_centerVertical="true"
? ? ?? android:layout_marginRight="23dp"
? ? ?? android:src="@drawable/ic_launcher_foreground" />
?? <ImageView
? ? ?? android:layout_width="20dp"
? ? ?? android:layout_height="20dp"
? ? ?? android:layout_marginRight="20dp"
? ? ?? android:layout_toLeftOf="@id/iv_test1"
? ? ?? android:layout_centerVertical="true"
? ? ?? android:src="@drawable/ic_launcher_foreground" />
</RelativeLayout>
實(shí)現(xiàn)效果:
如果想根據(jù)圖片上端對齊锭魔,只需設(shè)置 android:layout_alignTop="@id/iv_test1"
效果如圖:
案例二:做一個(gè)中間一個(gè)大控件、四周小空間控件分別對齊大控件的上下左右四個(gè)方向
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
?? android:layout_width="match_parent"
?? android:layout_height="match_parent"
? >
?? <RelativeLayout
? ? ?? android:layout_width="50dp"
? ? ?? android:layout_height="50dp"
? ? ?? android:background="#678"
? ? ?? android:layout_toLeftOf="@+id/rl_big"
? ? ?? android:layout_alignTop="@id/rl_big"
? ? ?? >
?? </RelativeLayout>
?? <RelativeLayout
? ? ?? android:layout_width="50dp"
? ? ?? android:layout_height="50dp"
? ? ?? android:background="#123"
? ? ?? android:layout_toRightOf="@+id/rl_big"
? ? ?? android:layout_alignBottom="@+id/rl_big"
? ? ?? >
?? </RelativeLayout>
?? <RelativeLayout
? ? ?? android:layout_width="50dp"
? ? ?? android:layout_height="50dp"
? ? ?? android:background="#886"
? ? ?? android:layout_above="@id/rl_big"
? ? ?? android:layout_alignRight="@id/rl_big"
? ? ?? >
?? </RelativeLayout>
?? <RelativeLayout
? ? ?? android:layout_width="50dp"
? ? ?? android:layout_height="50dp"
? ? ?? android:background="#886"
? ? ?? android:layout_below="@+id/rl_big"
? ? ?? android:layout_alignLeft="@id/rl_big"
? ? ?? >
?? </RelativeLayout>
?
?? <RelativeLayout
? ? ?? android:id="@+id/rl_big"
? ? ?? android:layout_width="160dp"
? ? ?? android:layout_height="160dp"
? ? ?? android:background="#ccc"
? ? ?? android:layout_centerInParent="true"></RelativeLayout>
</RelativeLayout>
效果圖:
ConstraintLayout(限制布局)
RelativeLayout+LinearLayout+x=ConstraintLayout路呜。第一感覺迷捧,這個(gè)布局好麻煩啊,第二感覺胀葱,有點(diǎn)意思漠秋,第三感覺,我得好好看看抵屿。
可以完全沒有嵌套庆锦,空間位置完全按照想要的角度去設(shè)計(jì) 按照牛客網(wǎng)的界面轧葛,用ConstraintLayout去實(shí)現(xiàn)以下搂抒。
屬性信息:? ? ?
在代碼中經(jīng)常有top bottom start end一些確定位置信息艇搀,用一張圖來解讀,
A控件:start是根布局求晶,也就是parent焰雕,top也是指向了根布局,也是parent芳杏,只看A控件矩屁,如果沒有別的設(shè)置,那么這兩個(gè)約束會讓它出現(xiàn)在左上角
B控件:start是A爵赵,top是c吝秕,end是根布局也就是parent,只看b控件空幻,那么它出現(xiàn)的位置一定是A控件的右邊 c控件的下面郭膛,而且是A控件和右邊邊界的中間。
ConstraintLayout有一個(gè)位置確定氛悬,那么其他的控件都可以根據(jù)這個(gè)控件確定好位置,解決了多層嵌套的問題耘柱。
常見為的位置設(shè)置信息(選取代碼中的一段)
1.app:layout_constraintBottom_toTopOf="@+id/guideline8"? 簡單理解為在某個(gè)空間的底部之上如捅,也就是在誰上面 這個(gè)是設(shè)置某個(gè)控件位置在guideline8之上
2.app:layout_constraintEnd_toEndOf="@+id/textView5" 同理 設(shè)置結(jié)束位置to結(jié)束位置,也就是當(dāng)前控件和textView5的結(jié)束位置相同
3.app:layout_constraintStart_toStartOf="@+id/textView5"設(shè)置開始位置to開始位置调煎,意味著開始位置相同
4.app:layout_constraintTop_toTopOf="@+id/guideline7"設(shè)置頂部位置為guideline7
5.app:layout_constraintHorizontal_bias="0.0" 水平位置百分比 范圍0~1之間镜遣,0為原點(diǎn),1為屏幕最右端士袄。還有一個(gè)垂直的悲关,同理
這個(gè)代碼中 2和3 確定了當(dāng)前控件與textView5垂直居中對齊。
這些就是大同小異了娄柳,不用可以記,根據(jù)上面的坐標(biāo)系想想就ok了
layout_constraintLeft_toLeftOf
layout_constraintLeft_toRightOf
layout_constraintRight_toLeftOf
layout_constraintRight_toRightOf
layout_constraintTop_toTopOf
layout_constraintTop_toBottomOf
layout_constraintBottom_toTopOf
layout_constraintBottom_toBottomOf
layout_constraintBaseline_toBaselineOf
layout_constraintStart_toEndOf
layout_constraintStart_toStartOf
layout_constraintEnd_toStartOf
layout_constraintEnd_toEndOf
工具簡單介紹
1.group 用組來控制控件寓辱,將iv_title,imageView,iv_test2放到一個(gè)組里,然后統(tǒng)一控制赤拒。一定要注意秫筏,這個(gè)不是把控件包裹起來(否則報(bào)錯(cuò):java.lang.ClassCastException: android.support.constraint.Group cannot be cast to android.view.ViewGroup)
<!--用組來控制控件-->
? ? ?? <android.support.constraint.Group
? ? ? ? ?? android:id="@+id/group"
? ? ? ? ?? android:background="#ff0"
? ? ? ? ?? android:layout_width="wrap_content"
? ? ? ? ?? android:layout_height="wrap_content"
? ? ? ? ?? app:constraint_referenced_ids="iv_title,imageView,iv_test2" />
2.guildLine 這個(gè)幫助布局控件的定位,有兩種形式挎挖,可以百分比定位也可以dp確認(rèn)位置这敬,非常靈活
?? <android.support.constraint.Guideline
? ? ?? android:id="@+id/guideline8"
? ? ?? android:layout_width="wrap_content"
? ? ?? android:layout_height="wrap_content"
? ? ?? android:orientation="horizontal"
? ? ?? app:layout_constraintGuide_percent="0.65" />
效果圖720*1280
效果圖1080*2340
效果完美 代碼如下
<?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">
?
?? <android.support.constraint.ConstraintLayout
? ? ?? android:layout_width="match_parent"
? ? ?? android:layout_height="wrap_content"
? ? ?? android:background="#666">
?? <TextView
? ? ?? android:id="@+id/iv_title"
? ? ?? android:layout_width="wrap_content"
? ? ?? android:layout_height="wrap_content"
? ? ?? android:layout_marginStart="16dp"
? ? ?? android:layout_marginTop="16dp"
? ? ?? android:layout_marginEnd="8dp"
? ? ?? android:text="牛客"
? ? ?? app:layout_constraintEnd_toEndOf="parent"
? ? ?? app:layout_constraintHorizontal_bias="0.0"
? ? ?? app:layout_constraintStart_toStartOf="parent"
? ? ?? app:layout_constraintTop_toTopOf="parent" />
?
?? <ImageView
? ? ?? android:id="@+id/imageView"
? ? ?? android:layout_width="30dp"
? ? ?? android:layout_height="30dp"
? ? ?? android:layout_marginEnd="80dp"
? ? ?? android:src="@mipmap/ic_pixaloop_question"
? ? ?? app:layout_constraintBottom_toBottomOf="@+id/iv_title"
? ? ?? app:layout_constraintEnd_toEndOf="parent"
? ? ?? app:layout_constraintLeft_toRightOf="@+id/iv_title"
? ? ?? app:layout_constraintTop_toTopOf="@+id/iv_title"
? ? ?? app:layout_constraintVertical_bias="0.5" />
?
?? <ImageView
? ? ?? android:layout_width="30dp"
? ? ?? android:layout_height="30dp"
? ? ?? android:layout_marginEnd="20dp"
? ? ?? android:src="@mipmap/ic_pixaloop_question"
? ? ?? app:layout_constraintBottom_toBottomOf="@+id/imageView"
? ? ?? app:layout_constraintEnd_toEndOf="parent"
? ? ?? app:layout_constraintLeft_toRightOf="@+id/iv_title"
? ? ?? app:layout_constraintTop_toTopOf="@+id/imageView"
? ? ?? app:layout_constraintVertical_bias="0.5" />
?? </android.support.constraint.ConstraintLayout>
?
?
?? <android.support.constraint.Guideline
? ? ?? android:id="@+id/guideline"
? ? ?? android:layout_width="wrap_content"
? ? ?? android:layout_height="wrap_content"
? ? ?? android:orientation="vertical"
? ? ?? app:layout_constraintGuide_percent="0.66" />
?? <android.support.constraint.Guideline
? ? ?? android:id="@+id/guideline2"
? ? ?? android:layout_width="wrap_content"
? ? ?? android:layout_height="wrap_content"
? ? ?? android:orientation="horizontal"
? ? ?? app:layout_constraintGuide_begin="41dp" />
?? <FrameLayout
? ? ?? android:id="@+id/frameLayout2"
? ? ?? android:layout_width="0dp"
? ? ?? android:layout_height="0dp"
? ? ?? android:layout_marginStart="8dp"
? ? ?? android:layout_marginTop="8dp"
? ? ?? android:layout_marginEnd="8dp"
? ? ?? android:background="#ccc"
? ? ? ?app:layout_constraintBottom_toTopOf="@+id/guideline3"
? ? ?? app:layout_constraintEnd_toEndOf="parent"
? ? ?? app:layout_constraintStart_toStartOf="parent"
? app:layout_constraintTop_toTopOf="@+id/guideline2">
? ? ?? <TextView
? ? ? ? ?? android:layout_width="327dp"
? ? ? ? ?? android:layout_height="45dp"
? ? ? ? ?? android:gravity="center"
? ? ? ? ?? android:textColor="@color/txt_selector"
? ? ? ? ?? android:text="ViewPager" />
?? </FrameLayout>
?? <android.support.constraint.Guideline
? ? ?? android:id="@+id/guideline3"
? ? ?? android:layout_width="wrap_content"
? ? ?? android:layout_height="wrap_content"
? ? ?? android:orientation="horizontal"
? ? ?? app:layout_constraintGuide_begin="143dp" />
?? <android.support.constraint.Guideline
? ? ?? android:id="@+id/guideline4"
? ? ?? android:layout_width="wrap_content"
? ? ?? android:layout_height="wrap_content"
? ? ?? android:orientation="horizontal"
? ? ?? app:layout_constraintGuide_percent="0.3561644" />
?? <TextView
? ? ?? android:id="@+id/textView2"
? ? ?? android:layout_width="wrap_content"
? ? ?? android:layout_height="20dp"
? ? ?? android:layout_marginStart="8dp"
? ? ?? android:layout_marginTop="5dp"
? ? ?? android:layout_marginEnd="8dp"
? ? ?? android:layout_marginBottom="8dp"
? ? ?? android:text="介紹信息"
? ? ?? app:layout_constraintBottom_toTopOf="@+id/guideline4"
? ? ?? app:layout_constraintEnd_toEndOf="parent"
? ? ?? app:layout_constraintHorizontal_bias="0.483"
? ? ?? app:layout_constraintStart_toStartOf="parent"
? ? ?? app:layout_constraintTop_toTopOf="@+id/guideline3" />
?
?? <android.support.constraint.Guideline
? ? ?? android:id="@+id/guideline5"
? ? ?? android:layout_width="wrap_content"
? ? ?? android:layout_height="wrap_content"
? ? ?? android:orientation="vertical"
? ? ?? app:layout_constraintGuide_percent="0.33" />
?? <android.support.constraint.Guideline
? ? ?? android:id="@+id/guideline7"
? ? ?? android:layout_width="wrap_content"
? ? ?? android:layout_height="wrap_content"
? ? ?? android:orientation="horizontal"
? ? ?? app:layout_constraintGuide_percent="0.5" />
?? <android.support.constraint.Guideline
? ? ?? android:id="@+id/guideline8"
? ? ?? android:layout_width="wrap_content"
? ? ?? android:layout_height="wrap_content"
? ? ?? android:orientation="horizontal"
? ? ?? app:layout_constraintGuide_percent="0.65" />
?? <TextView
? ? ?? android:id="@+id/textView4"
? ? ?? android:layout_width="wrap_content"
? ? ?? android:layout_height="wrap_content"
? ? ?? android:layout_marginStart="16dp"
? ? ?? android:layout_marginTop="8dp"
? ? ?? android:layout_marginEnd="8dp"
? ? ?? android:layout_marginBottom="8dp"
? ? ?? android:text="TextView"
? ? ?? app:layout_constraintBottom_toTopOf="@+id/guideline7"
? ? ?? app:layout_constraintEnd_toStartOf="@+id/guideline5"
? ? ?? app:layout_constraintStart_toStartOf="parent"
? ? ?? app:layout_constraintTop_toTopOf="@+id/guideline4"
? ? ?? app:layout_constraintVertical_bias="0.5" />
?? <TextView
? ? ?? android:id="@+id/textView5"
? ? ?? android:layout_width="wrap_content"
? ? ?? android:layout_height="wrap_content"
? ? ?? android:text="TextView"
? ? ?? app:layout_constraintBottom_toBottomOf="@+id/textView4"
? ? ?? app:layout_constraintEnd_toEndOf="parent"
? ? ?? app:layout_constraintStart_toStartOf="parent"
? ? ?? app:layout_constraintTop_toTopOf="@+id/textView4" />
?? <TextView
? ? ?? android:id="@+id/textView6"
? ? ?? android:layout_width="wrap_content"
? ? ?? android:layout_height="19dp"
? ? ?? android:layout_marginStart="8dp"
? ? ?? android:layout_marginEnd="8dp"
? ? ?? android:text="TextView"
? ? ?? app:layout_constraintBottom_toBottomOf="@+id/textView5"
? ? ?? app:layout_constraintEnd_toEndOf="parent"
? ? ?? app:layout_constraintStart_toStartOf="@+id/guideline"
? ? ?? app:layout_constraintTop_toTopOf="@+id/textView5" />
?? <TextView
? ? ?? android:id="@+id/textView7"
? ? ?? android:layout_width="wrap_content"
? ? ?? android:layout_height="wrap_content"
? ? ?? android:layout_marginTop="8dp"
? ? ?? android:layout_marginBottom="8dp"
? ? ?? android:text="TextView"
? ? ?? app:layout_constraintBottom_toTopOf="@+id/guideline8"
? ? ?? app:layout_constraintEnd_toEndOf="@+id/textView4"
? ? ?? app:layout_constraintStart_toStartOf="@+id/textView4"
? ? ?? app:layout_constraintTop_toTopOf="@+id/guideline7" />
?
?? <TextView
? ? ?? android:id="@+id/textView8"
? ? ?? android:layout_width="wrap_content"
? ? ?? android:layout_height="wrap_content"
? ? ?? android:layout_marginTop="8dp"
? ? ?? android:layout_marginBottom="8dp"
? ? ?? android:text="TextView"
? ? ?? app:layout_constraintBottom_toTopOf="@+id/guideline8"
? ? ?? app:layout_constraintEnd_toEndOf="@+id/textView5"
? ? ?? app:layout_constraintStart_toStartOf="@+id/textView5"
? ? ?? app:layout_constraintTop_toTopOf="@+id/guideline7"
? ? ?? app:layout_constraintVertical_bias="0.514" />
?
?? <TextView
? ? ?? android:id="@+id/textView9"
? ? ?? android:layout_width="wrap_content"
? ? ?? android:layout_height="wrap_content"
? ? ?? android:layout_marginTop="8dp"
? ? ?? android:layout_marginBottom="8dp"
? ? ?? android:text="TextView"
? ? ?? app:layout_constraintBottom_toTopOf="@+id/guideline8"
? ? ?? app:layout_constraintEnd_toEndOf="@+id/textView6"
? ? ?? app:layout_constraintStart_toStartOf="@+id/textView6"
? ? ?? app:layout_constraintTop_toTopOf="@+id/guideline7"
? ? ?? app:layout_constraintVertical_bias="0.512" />
?
?? <android.support.constraint.Guideline
? ? ?? android:id="@+id/guideline9"
? ? ?? android:layout_width="wrap_content"
? ? ?? android:layout_height="wrap_content"
? ? ?? android:orientation="horizontal"
? ? ?? app:layout_constraintGuide_end="50dp" />
?
?? <RadioGroup
? ? ?? android:id="@+id/rgp_bottom_menu"
? ? ?? android:layout_width="match_parent"
? ? ?? android:layout_height="wrap_content"
? ? ?? android:layout_marginTop="8dp"
? ? ?? android:layout_marginEnd="8dp"
? ? ?? android:layout_marginBottom="15dp"
? ? ?? android:gravity="center"
? ? ?? android:orientation="horizontal"
? ? ?? app:layout_constraintBottom_toBottomOf="parent"
? ? ?? app:layout_constraintEnd_toEndOf="parent"
? ? ?? app:layout_constraintStart_toStartOf="parent"
? ? ?? app:layout_constraintTop_toTopOf="@+id/guideline9">
?
? ? ?? <RadioButton
? ? ? ? ?? android:id="@+id/rb_study"
? ? ? ? ?? android:layout_width="0dp"
? ? ? ? ?? android:layout_height="wrap_content"
? ? ? ? ?? android:layout_weight="1"
? ? ? ? ?? android:button="@null"
? ? ? ? ?? android:clickable="true"
? ? ? ? ?? android:textColor="@color/txt_selector"
? ? ? ? ?? android:drawableTop="@drawable/click"
? ? ? ? ?? android:gravity="center"
? ? ? ? ?? android:text="學(xué)習(xí)" />
?
? ? ?? <RadioButton
? ? ? ? ?? android:id="@+id/rb_community"
? ? ? ? ?? android:layout_width="0dp"
? ? ? ? ?? android:layout_height="wrap_content"
? ? ? ? ?? android:layout_weight="1"
? ? ? ? ?? android:button="@null"
? ? ? ? ?? android:textColor="@color/txt_selector"
? ? ? ? ?? android:drawableTop="@drawable/click"
? ? ? ? ?? android:gravity="center"
? ? ? ? ?? android:text="社區(qū)" />
?
? ? ?? <RadioButton
? ? ? ? ?? android:id="@+id/rb_message"
? ? ? ? ?? android:layout_width="0dp"
? ? ? ? ?? android:layout_height="wrap_content"
? ? ? ? ?? android:layout_weight="1"
? ? ? ? ?? android:button="@null"
? ? ? ? ?? android:textColor="@color/txt_selector"
? ? ? ? ?? android:drawableTop="@drawable/click"
? ? ? ? ?? android:gravity="center"
? ? ? ? ?? android:text="消息" />
?
? ? ?? <RadioButton
? ? ? ? ?? android:id="@+id/rb_myNk"
? ? ? ? ?? android:layout_width="0dp"
? ? ? ? ?? android:layout_height="wrap_content"
? ? ? ? ?? android:layout_weight="1"
? ? ? ? ?? android:button="@null"
? ? ? ? ?? android:textColor="@color/txt_selector"
? ? ? ? ?? android:drawableTop="@drawable/click"
? ? ? ? ?? android:gravity="center"
? ? ? ? ?? android:text="我的沤抖洌客" />
?
?? </RadioGroup>
?
?? <Button
? ? ?? android:id="@+id/button"
? ? ?? android:layout_width="0dp"
? ? ?? android:layout_height="0dp"
? ? ?? android:layout_marginTop="8dp"
? ? ?? android:layout_marginBottom="8dp"
? ? ?? android:background="#b5f5f4"
? ? ?? android:text="我是隨便填充的內(nèi)容"
? ? ?? app:layout_constraintBottom_toTopOf="@+id/rgp_bottom_menu"
? ? ?? app:layout_constraintEnd_toEndOf="parent"
? ? ?? app:layout_constraintStart_toStartOf="parent"
? ? ?? app:layout_constraintTop_toTopOf="@+id/guideline8" />
</android.support.constraint.ConstraintLayout>
?
幾乎沒有嵌套,用起來非常爽崔涂。