当前位置: 首页 > news >正文

Android学习(五):常用控件

Android学习(五):常用控件

常用控件

  • TextView
  • EditText
  • Button
  • RadioButton
  • ImageView

1、TextView控件

1.1、简介

TextView是用于显示文字(字符串)的控件,可在代码中通过设置属性改变文字的大小、颜色、样式等功能。

1.2、示例
<TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/hello_android"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintLeft_toLeftOf="parent"app:layout_constraintRight_toRightOf="parent"app:layout_constraintTop_toTopOf="parent" />

2、EditText控件

2.1、简介

EditText继承自TextView,可以进行编辑操作,将用户信息传递给Android程序。还可以为EditText控件设置监听器,用来测试用户输入的内容是否合法。

2.2、示例
<EditTextandroid:id="@+id/editText"android:layout_width="wrap_content"android:layout_height="wrap_content"android:ems="10"android:inputType="textPassword"tools:layout_editor_absoluteX="64dp"tools:layout_editor_absoluteY="179dp"tools:ignore="LabelFor,MissingConstraints"android:autofillHints="11" />

3、Button控件

3.1、简介

Button是按钮,是用于响应用户的一系列点击事件,使程序更加流畅和完整。

3.2、示例
<Buttonandroid:id="@+id/button"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Button"tools:layout_editor_absoluteX="133dp"tools:layout_editor_absoluteY="431dp"tools:ignore="MissingConstraints" />

4、RadioButton控件

4.1、简介
  • RadioButton为单选按钮,它需要与RadioGroup配合使用,提供两个或多个互斥的选项集。
  • RadioGroup是单选组合框,可容纳多个RadioButton,并把它们组合在一起,实现单选状态。
4.2、示例
<RadioButtonandroid:id="@+id/radioButton"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="RadioButton"tools:layout_editor_absoluteX="116dp"tools:layout_editor_absoluteY="512dp"tools:ignore="MissingConstraints" />

5、ImageView控件

5.1、简介

ImageView是视图控件,它继承自View,其功能是在屏幕中显示图像。ImageView类可以从各种来源加载图像(如资源库或网络),并提供缩放、裁剪、着色(渲染)等功能。

5.2、示例
<ImageViewandroid:id="@+id/imageView"android:layout_width="wrap_content"android:layout_height="wrap_content"app:srcCompat="@drawable/ic_launcher_background"tools:layout_editor_absoluteX="130dp"tools:layout_editor_absoluteY="112dp"tools:ignore="MissingConstraints,VectorDrawableCompat"android:contentDescription="@string/todo" />
http://www.lryc.cn/news/284721.html

相关文章:

  • 基于YOLOv8的学生课堂行为检测,引入BRA注意力和Shape IoU改进提升检测能力
  • 【前后端分离与不分离的区别】
  • ubuntu-20.04.6-live-server-amd64安装教程-完整版
  • C for Graphic:Sliced Circle Image
  • 入门级的 DataV 教程,适用于 Vue 2
  • JVM工作原理与实战(二十一):内存管理
  • Win10 打开文件突然鼠标变成一个蓝色大圈卡住点不了也打不开文件,重启电脑也是这样
  • 论文阅读笔记AI篇 —— Transformer模型理论+实战 (四)
  • Template -- Vue2
  • zookeeper window 安装
  • Redis 面试题 | 02.精选Redis高频面试题
  • 大数据开发之kafka(完整版)
  • 单体架构、微服务和无服务器架构
  • Github仓库使用方式
  • Harmony Ble蓝牙App(四)描述符
  • C# 实现单线程异步互斥锁
  • Java设计模式中策略模式可以解决许多if-else的代码结构吗? 是否能满足开闭原则?
  • [C#]C# winform部署yolov8目标检测的openvino模型
  • 力扣刷MySQL-第五弹(详细讲解)
  • 用C语言实现简单的三子棋游戏
  • Yaklang 中的类型和变量
  • C语言从入门到实战——编译和链接
  • 【实战教程】ThinkPHP6分页功能轻松实现,让你的网站更高效!
  • 专业130+总分380+哈尔滨工程大学810信号与系统考研经验水声电子信息与通信
  • 旅游项目day08
  • 蓝桥杯真题(Python)每日练Day2
  • IntelliJ IDEA 拉取gitlab项目
  • RHCSA上课笔记(前半部分)
  • C++代码入门05 字符串容器
  • vue3 项目中 arguments 对象获取失败问题