基本的UI界面设计

使用的组件

TextView、EditText、ConstraintLayout、Button、ImageView、RadioGroup、RadioButton。


三、课堂实验结果

(1)实验截图



(2)实验步骤以及关键代码

首先在布局文件中创建一个新的XML文件,然后安装指导中的,采用约束布局,先做最顶层的标题和图片

   android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context=".MainActivity">    <TextView        android:id="@+id/title"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginTop="20dp"        android:text="中山大学智慧健康服务平台"        android:textColor="@color/black"        android:textSize="20sp"        app:layout_constraintLeft_toLeftOf="parent"        app:layout_constraintRight_toRightOf="parent"        app:layout_constraintTop_toTopOf="parent" />    <ImageView        android:id="@+id/image"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginTop="20dp"        android:src="@mipmap/sysu"        app:layout_constraintLeft_toLeftOf="parent"        app:layout_constraintRight_toRightOf="parent"        app:layout_constraintTop_toBottomOf="@id/title" />

之后是是搜索框还有搜索按钮

<EditText        android:id="@+id/text1"        android:layout_width="0dp"        android:layout_height="wrap_content"        android:layout_marginLeft="20dp"        android:layout_marginTop="20dp"        android:gravity="center"        android:hint="请输入搜索内容"        android:textSize="18sp"        app:layout_constraintLeft_toLeftOf="parent"        app:layout_constraintRight_toLeftOf="@id/button"        app:layout_constraintTop_toBottomOf="@id/image" />    <Button        android:id="@+id/button"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginRight="20dp"        android:layout_marginTop="20dp"        android:layout_marginLeft="10dp"        android:text="搜索"        android:textColor="#FFFFFF"        android:background="@drawable/buttonstyle"        android:textSize="18sp"        app:layout_constraintRight_toRightOf="parent"        app:layout_constraintLeft_toRightOf="@id/text1"        app:layout_constraintTop_toBottomOf="@id/image" />
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android">    <solid android:color="#3F51B5"/>    <corners android:radius="180dp"/>    <padding        android:top="5dp"        android:bottom="5dp"        android:left="10dp"        android:right="10dp"/>shape>

还有组单选按钮

<RadioGroup        android:id="@+id/radioGroup"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        app:layout_constraintTop_toBottomOf="@id/text1"        android:layout_marginTop="10dp"        app:layout_constraintLeft_toLeftOf="parent"        app:layout_constraintRight_toRightOf="parent"        android:orientation="horizontal">        <RadioButton            android:id="@+id/button1"            style="@style/myButton"            android:checked="true"            android:text="图片"            android:layout_marginLeft="10dp" />        <RadioButton            android:id="@+id/button2"            style="@style/myButton"            android:text="视频" />        <RadioButton            android:id="@+id/button3"            style="@style/myButton"            android:text="问答" />        <RadioButton            android:id="@+id/button4"            style="@style/myButton"            android:text="资讯" />RadioGroup>
<resources>        <style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">                "colorPrimary">@color/colorPrimary        "colorPrimaryDark">@color/colorPrimaryDark        "colorAccent">@color/gray    style>    <style name="myButton">        "android:layout_width">wrap_content        "android:layout_height">wrap_content        "android:textSize">18sp        "android:layout_weight">1        "android:layout_marginRight">10dp    style>resources>

更多相关文章

  1. Android(安卓)GridView 的使用
  2. 新浪微博布局学习——妙用TabHost
  3. android 的view类的setVisibility();值的意思
  4. 【Android(安卓)Studio 学习】—— day 01
  5. 【Android】一个简单又实用的toolbar
  6. android开发教程之listview使用方法
  7. Android(安卓)流式布局(标签效果)
  8. Android:TabLayout向上滑动停留页面顶部
  9. 简单介绍安卓的五大布局

随机推荐

  1. MySql基本查询-基本函数
  2. Elasticsearch的基础语法
  3. 用 Python 制作一个迷宫游戏
  4. python实现Hangman游戏
  5. 微信API接口监控
  6. web前端中涉及的回流和重绘详解!
  7. SumSwap节点预售开启,新的DEX挑战者即将
  8. vite 中文网
  9. Unity 3D网页游戏与flash网页游戏的较量
  10. 这可能是全网关于Camera慢动作录像(SlowMo