目录 | 链接 |
---|---|
一,项目实验——Android 线性布局 | http://t.csdnimg.cn/yDK2c |
二,项目实验——Android 约束布局 | http://t.csdnimg.cn/TS73B |
三,个性化定制App登录界面 | http://t.csdnimg.cn/x7q7D |
四,项目实验——Activity与Intent | http://t.csdnimg.cn/BlTbs |
一. 简答题(共1题,100分)
-
(简答题)
(1)项目目标:掌握约束布局的使用方法及应用。
(2)项目任务:使用约束布局完成UI界面的设计。
(3)任务内容: -
任务:使用ConstraintLayout完成一个“注册个人信息”的布局。
-
创建项目ConstraintLayoutDemo,包名:cn.edu.baiyunu.constraintlayoutdemo,Language:
Java 。 -
组件树如下图所示:
-
运行效果图:
实验2 运行效果图
实验素材下载↓
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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:background="@drawable/img2"
tools:context=".MainActivity">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:textSize="40dp"
android:text="Registration"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintRight_toRightOf="parent"
/>
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
android:layout_marginLeft="20dp"
android:layout_marginTop="70dp"
app:layout_constraintTop_toBottomOf="@+id/title"
app:layout_constraintLeft_toLeftOf="parent"/>
<EditText
android:id="@+id/input_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="Please input your name"
android:layout_marginRight="20dp"
android:layout_marginTop="55dp"
android:layout_marginLeft="10dp"
app:layout_constraintLeft_toRightOf="@+id/name"
app:layout_constraintTop_toBottomOf="@id/title"
app:layout_constraintRight_toRightOf="parent"
/>
<TextView
android:id="@+id/id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="50dp"
android:text="ID"
app:layout_constraintTop_toBottomOf="@+id/name"
app:layout_constraintLeft_toLeftOf="parent"/>
<EditText
android:id="@+id/input_id"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:hint="Please input your ID"
android:layout_marginLeft="30dp"
android:layout_marginTop="20dp"
app:layout_constraintLeft_toRightOf="@+id/id"
app:layout_constraintTop_toBottomOf="@id/input_name"
app:layout_constraintRight_toRightOf="parent" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Gender"
android:textSize="15dp"
android:layout_marginTop="70dp"
android:layout_marginLeft="20dp"
app:layout_constraintTop_toBottomOf="@+id/id"
app:layout_constraintLeft_toLeftOf="parent"/>
<RadioGroup
android:id="@+id/radioGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginLeft="-180dp"
android:layout_marginTop="50dp"
app:layout_constraintTop_toBottomOf="@id/input_id"
app:layout_constraintLeft_toRightOf="@id/textView"
app:layout_constraintRight_toRightOf="parent">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Male"
android:textSize="15dp"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Female"
android:textSize="15dp"/>
</RadioGroup>
<Button
android:layout_marginBottom="30dp"
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="115dp"
android:text="Submit"
app:layout_constraintRight_toLeftOf="@+id/btn2"
app:layout_constraintBottom_toBottomOf="parent"/>
<Button
android:layout_marginBottom="30dp"
android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="115dp"
android:text="Reset"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"/>
<Button
android:id="@+id/btn3"
android:layout_marginBottom="30dp"
android:layout_width="wrap_content"
android:width="115dp"
android:layout_height="wrap_content"
android:text="Exit"
app:layout_constraintLeft_toRightOf="@+id/btn2"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>