Android常用控件

Android控件的相同属性

  • 所有控件都有的4个属性:id、layout_width以及layout_height和android:visibility;

Butoon

  • Butoon控件是Android程序开发中最常用的控件之一主要功能是通过单机Button来触发来完成一系列的事件,然后加上监听器来实现监听事件。
    以下展示一些常见的属性。
 

ImageButton

  • ImageButton控件是图片控件,同Button控件相似都是通过点击当前控件来触发一系列事件,加上监听器来实现监听事件。
    以下展示一些常见的属性。
<ImageButton        android:layout_width="100dp"        android:layout_height="100dp"        android:id="@+id/Im_sc"          android:layout_marginTop="100dp"        android:src="@mipmap/ic_launcher"/>

TextView

  • TextView也是 Android 程序开发中最常用的控件之一,主要功能是向用户展示文本的内容,它是不可编辑的 ,只能通过初始化设置或在程序中修改。
    以下展示一些常见的属性。
 "wrap_content"         android:layout_height="wrap_content"         android:text="姓名:"         android:textSize="20dp"         android:id="@+id/tv_name"         />

EidtView

  • EidtView与TextView相似,不过EidtView是可以编辑的,可以和用户进行 交互。
    以下展示一些常见的属性。
<EditText         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:hint="请输入您的名字"          android:textSize="20dp"         />

ImageView

  • ImageView是一个图片控件,负责显示图片,既可以用系统提供的资源文件,也可以用 Drawable 对象,且ImageView和ImageButton, 很多属性都是相同的。
    以下展示一下常见的属性。
<ImageView        android:layout_width="match_parent"        android:layout_height="match_parent"        android:src="@mipmap/ic_launcher"        android:id="@+id/Iv_tp"        android:scaleType="fitXY"        />

CheckBox

  • CheckBox是复选按钮,是一种可以进行多选的按钮,默认以矩形表示。它有选中或者不选中双状态。我们可以先在布局文件中定义多选按钮, 然后对每一个多选按钮进行事件监听 setOnCheckedChangeListener,通过 isChecked 来判断 选项是否被选中,做出相应的事件响应。
 id="@+id/cb1"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:text="九江"        android:textSize="30sp"       android:textColor="#0000FF"       android:textStyle="normal" />    id="@+id/cb2"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:text="南昌"        android:textSize="30sp"        android:textColor="#0000FF"/>

ProgressBar

  • ProgressBar 用于在界面上显示一个进度条,表示我们的程序正在加载一些数据,运行程序,会看到屏幕中有一个圆形进度条正在旋转。
    以下展示一些常见的属性。
<ProgressBar        android:id="@+id/pb"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_alignTop="@+id/bt_ks" />

更多相关文章

  1. Android 自定义控件实现刮刮卡效果 真的就只是刮刮卡么
  2. Android shap 控件美化
  3. 关于android 双击事件
  4. [置顶] Android中_TextView属性的XML详解 包括单行显示等等。

随机推荐

  1. php全称是什么
  2. php 的生命周期
  3. PHP保留类及特殊类
  4. php header是什么意思
  5. php隐藏后缀(.PHP)的方法过程
  6. PHP 引用详解 - 踩坑与妙用
  7. php如何理解面向对象
  8. PHP 源码 — is_array 函数源码分析
  9. php和前端的区别
  10. 三分钟了解PHP 7.4新特性