[职业竞赛][移动应用]Andriod布局器和控件的主要属性卡片式手册

Android布局示例及常用属性

<?xml version="1.0" encoding="utf-8"?>
<!-- 根布局:垂直方向的线性布局 -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"    <!-- 宽度充满父容器 -->
    android:layout_height="match_parent"   <!-- 高度充满父容器 -->
    android:orientation="vertical"        <!-- 子元素垂直排列 -->
    android:padding="16dp">                <!-- 内边距16dp -->
    <!-- 标题文本 -->
    <TextView
        android:id="@+id/title"           <!-- 唯一ID标识 -->
        android:layout_width="wrap_content" <!-- 宽度自适应内容 -->
        android:layout_height="wrap_content" <!-- 高度自适应内容 -->
        android:text="用户登录"            <!-- 显示文本 -->
        android:textSize="24sp"            <!-- 字体大小24sp -->
        android:textColor="#000000"        <!-- 字体颜色黑色 -->
        android:layout_gravity="center"   <!-- 在父容器中居中 -->
        android:layout_marginBottom="20dp"/> <!-- 底部外边距20dp -->

    <!-- 用户名输入框 -->
    <EditText
        android:id="@+id/et_username"
        android:layout_width="match_parent" <!-- 宽度充满父容器 -->
        android:layout_height="wrap_content"
        android:hint="请输入用户名"        <!-- 提示文本 -->
        android:inputType="text"           <!-- 输入类型为文本 -->
        android:padding="12dp"             <!-- 内边距12dp -->
        android:background="@drawable/edittext_bg" <!-- 自定义背景 -->
        android:layout_marginBottom="10dp"/> 

    <!-- 密码输入框 -->
    <EditText
        android:id="@+id/et_password"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="请输入密码"
        android:inputType="textPassword"   <!-- 密码输入类型 -->
        android:padding="12dp"
        android:background="@drawable/edittext_bg"
        android:layout_marginBottom="20dp"/>

    <!-- 登录按钮 -->
    <Button
        android:id="@+id/btn_login"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="登录"
        android:textColor="#FFFFFF"        <!-- 白色文字 -->
        android:backgroundTint="#6200EE"   <!-- 按钮背景色 -->
        android:onClick="onLoginClick"     <!-- 点击事件绑定 -->
        android:layout_marginTop="10dp"/>  <!-- 顶部外边距 -->

    <!-- 水平排列的辅助链接 -->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"   <!-- 子元素水平排列 -->
        android:gravity="center">          <!-- 子元素居中 -->

        <TextView
            android:id="@+id/tv_forgot"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="忘记密码?"
            android:textColor="#6200EE"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="|"
            android:layout_marginHorizontal="8dp"/> <!-- 左右外边距 -->

        <TextView
            android:id="@+id/tv_register"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="注册账号"
            android:textColor="#6200EE"/>
    </LinearLayout>
</LinearLayout>
属性名称 说明
android:layout_width 控件宽度(match_parent充满父容器,wrap_content自适应内容,固定值)
android:layout_height 控件高度(用法同上)
android:id 唯一资源ID标识(@+id/控件名)
android:layout_margin 外边距(可单独设置left/right/top/bottom)
android:padding 内边距(可单独设置left/right/top/bottom)
android:orientation 布局方向(vertical垂直排列,horizontal水平排列)
android:text 显示文本内容("文本"或@string/资源)
android:background 背景(颜色#FFFFFF或图片@drawable/资源)
android:layout_gravity 在父容器中的对齐方式(center,right,bottom等)
android:gravity 子元素对齐方式(center,start,end等)

常见控件及事件说明

控件类型 控件名称(Android) 典型事件(Kotlin风格) 触发时机 常见应用场景
按钮 Button onClick 鼠标点击或键盘回车确认时触发 提交表单、触发操作
ImageButton onMouseEnter/onMouseLeave 鼠标悬停/离开控件区域时触发 显示悬停提示、动态效果
文本框 EditText onTextChanged 文本内容发生改变时触发 实时搜索、输入验证
TextInputEditText onKeyDown/onKeyUp 键盘按键按下/释放时触发 快捷键处理、输入限制
复选框 CheckBox onCheckedChange 选中状态改变时触发 选项切换、条件过滤
下拉列表 Spinner onSelectedIndexChange 选中项发生变化时触发 级联选择、数据分类
单选框组 RadioGroup onCheckedChange 选项变更时触发(需判断当前选中项) 单选设置、模式切换
滑块 SeekBar onValueChange 滑块数值变化时触发 音量调节、参数实时调整
菜单项 MenuItem onClick 点击菜单项时触发 导航、命令执行
列表项 ListView onSelectedIndexChange 选中项变化时触发 详情展示、数据操作
RecyclerView onItemClick 点击单项时触发(部分框架特有) 交互式列表操作
图片 ImageView onClick 点击图片时触发 图片查看器、交互式图鉴
超链接 TextView onClick 点击链接时触发(可取消默认跳转行为) 自定义导航、统计点击
底部导航 BottomNavigationView setOnItemSelectedListener / setOnItemReselectedListener 选中新的导航项 / 重复点击当前已选中的项时触发 应用主要模块的一级页面切换

事件处理代码示例


// 按钮点击事件示例(假设在 Activity/Fragment 中)
button1.setOnClickListener 
【四旋翼无人机】具备螺旋桨倾斜机构的全驱动四旋翼无人机:建模与控制研究(Matlab代码、Simulink仿真实现)内容概要:本文围绕具备螺旋桨倾斜机构的全驱动四旋翼无人机展开研究,重点探讨其系统建模与控制策略,结合Matlab代码与Simulink仿真实现。文章详细分析了无人机的动力学模型,特别是引入螺旋桨倾斜机构后带来的全驱动特性,使其在姿态与位置控制上具备更强的机动性与自由度。研究涵盖了非线性系统建模、控制设计(如PID、MPC、非线性控制等)、仿真验证及动态响应分析,旨在提升无人机在复杂环境下的稳定性控制精度。同时,文中提供的Matlab/Simulink资源便于读者复现实验并进一步优化控制算法。; 适合人群:具备一定控制理论基础Matlab/Simulink仿真经验的研究生、科研人员及无人机控制系统开发工程师,尤其适合从事飞行建模与先进控制算法研究的专业人员。; 使用场景及目标:①用于全驱动四旋翼无人机的动力学建模与仿真平台搭建;②研究先进控制算法(如模型预测控制、非线性控制)在无人机系统中的应用;③支持科研论文复现、课程设计或毕业课题开发,推动无人机高机动控制技术的研究进展。; 阅读建议:建议读者结合文档提供的Matlab代码与Simulink模型,逐步实现建模与控制算法,重点关注坐标系定义、力矩分配逻辑及控制闭环的设计细节,同时可通过修改参数添加扰动来验证系统的鲁棒性与适应性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值