深圳全飞鸿

标题: 关于ConstraintLayout [打印本页]

作者: syant    时间: 2024-11-30 23:35
标题: 关于ConstraintLayout
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.     xmlns:app="http://schemas.android.com/apk/res-auto"
  4.     xmlns:tools="http://schemas.android.com/tools"
  5.     android:layout_width="match_parent"
  6.     android:layout_height="match_parent"
  7.     tools:context=".MainActivity">

  8.     <TextView
  9.         android:id="@+id/test"
  10.         android:layout_width="wrap_content"
  11.         android:layout_height="wrap_content"
  12.         android:text="@string/test"
  13.         android:textSize="20sp"
  14.         android:padding="10dp"
  15.         android:layout_marginTop="20dp"
  16.         app:layout_constraintLeft_toLeftOf="parent"
  17.         app:layout_constraintRight_toRightOf="parent"
  18.         app:layout_constraintTop_toTopOf="parent" />

  19.     <TextView
  20.         android:id="@+id/k_default"
  21.         android:layout_width="wrap_content"
  22.         android:layout_height="wrap_content"
  23.         android:text="@string/default_language"
  24.         android:textSize="20sp"
  25.         android:padding="10dp"
  26.         android:layout_marginTop="20dp"
  27.         android:textColor="#FFFFFF"
  28.         android:background="@color/colorPrimary"
  29.         app:layout_constraintTop_toBottomOf="@+id/test"
  30.         app:layout_constraintLeft_toLeftOf="parent"
  31.         app:layout_constraintRight_toRightOf="parent"/>
  32.     <TextView
  33.         android:id="@+id/chinese"
  34.         android:layout_width="wrap_content"
  35.         android:layout_height="wrap_content"
  36.         android:text="@string/chinese"
  37.         android:textSize="20sp"
  38.         android:padding="10dp"
  39.         android:layout_marginTop="20dp"
  40.         android:textColor="#FFFFFF"
  41.         android:background="@color/colorPrimary"
  42.         app:layout_constraintTop_toBottomOf="@+id/k_default"
  43.         app:layout_constraintLeft_toLeftOf="parent"
  44.         app:layout_constraintRight_toRightOf="parent"/>

  45.     <TextView
  46.         android:id="@+id/english"
  47.         android:layout_width="wrap_content"
  48.         android:layout_height="wrap_content"
  49.         android:layout_marginTop="44dp"
  50.         android:background="@color/colorPrimary"
  51.         android:padding="10dp"
  52.         android:text="@string/english"
  53.         android:textColor="#FFFFFF"
  54.         android:textSize="20sp"
  55.         app:layout_constraintHorizontal_bias="0.498"
  56.         app:layout_constraintLeft_toLeftOf="parent"
  57.         app:layout_constraintRight_toRightOf="parent"
  58.         app:layout_constraintTop_toBottomOf="@+id/chinese" />
  59. </android.support.constraint.ConstraintLayout>
复制代码







欢迎光临 深圳全飞鸿 (http://www.nagomes.com/disc/) Powered by Discuz! X3.2