ConstraintLayout 水平比例布局 1:1:2
//以下代码展示了一个 1:1:2的ConstraintLayout布局, 关键点就是 位置的left,right的摆放,才能出现这个效果。 认真体会
<?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.okaylens.it8951demo.MainActivity">
<Button
android:id="@+id/connect_usb_bt"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintRight_toLeftOf="@id/send_bmp_bt"
android:layout_width="0dp"
android:layout_height="100dp"
/>
<Button
app:layout_constraintTop_toTopOf="parent"
android:id="@+id/send_bmp_bt"
app:layout_constraintLeft_toRightOf="@id/connect_usb_bt"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintRight_toLeftOf="@id/send_jpg_bt"
android:layout_width="0dp"
android:layout_height="100dp"
/>
<Button
app:layout_constraintTop_toTopOf="parent"
android:id="@+id/send_jpg_bt"
app:layout_constraintLeft_toRightOf="@id/send_bmp_bt"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintHorizontal_weight="2"
android:layout_width="0dp"
android:layout_height="100dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</android.support.constraint.ConstraintLayout>