Android基本控件

TextView简介

属性名称 作用描述
android:layout_width 设置控件的宽度
android:layout_height 设置控件的高度
android:id 设置控件的ID
android:text 设置文本的内容
android:textColor 设置文本的颜色
android:textSize 设置文本的大小
android:background 设置控件的背景色
android:gravity 设置文本相对控件的位置
android:layout_gravity 设置控件相对于其所在容器的位置

Android基本控件

Button简介

Button控件和TextVIew控件很多相似。
Android基本控件
Android基本控件

ImageView简介

属性名称 作用描述
android:adjustViewBounds 是否保持宽高比,需要与maxWidth,maxHeight一起使用,否则没有效果
android:cropToPadding 是否截取指定区域用空白代替,单独设置无效,需要与scrollY一起使用
android:maxHeight 设置View的最大高度
android:maxWidth 设置View的最大宽度
android:src 用于设置ImageView中展示图片
android:scaleType 设置图片的填充方式
android:tint 将图片渲染成指定的颜色

Android基本控件
效果如下:
Android基本控件

EditView简介

属性名称 作用描述
android:inputType 设置文本类型
android:digits 设置允许输入哪些字符
android:hint 设置编辑框内容为空时显示的提示信息
android:password 设置只能输入密码,以…显示
android:singleLine 设置文本单行显示
android:editable 设置是否可编辑
requestFocus() 使当前组件对象获得焦点
android:phoneNumber 设置电话号码输入的方式
android:ems 设置控件的宽度为N个字符

Android基本控件
Android基本控件
效果如下:
Android基本控件

关键代码

1.获取用户名、密码和按钮这几个控件
Android基本控件
2. 跳转页面代码
Android基本控件
3.跑马灯
Android基本控件
4.获取RadioButton点击事件
取消点击事件
setImageResource获取资源
Android基本控件
5.关闭软键盘

Android基本控件
6.消除黄色背景
Android基本控件
7.将输入的数字转换成Ip地址形式Android基本控件
8.设置消息传递的动作,通过PendingIntent进行传递(自定义Intent跳转的第二个Activity需要自行定义)Android基本控件