基础组件

1.TextView

1. text 文本 setText getText2. textColor 文本颜色 #FFFFFF setTextColor getTextColor3. textSize 文本大小 sp setTextColor(Color.Blue) getTextColor();4. textSytle 文本样式 没有java代码 (设置画笔)5. gravity 文本对齐方式 center 

2.Button

根TextView一样

3.ImageView

1.src 前置图片 setImageResource(R.drawable.xxx);2. scaleType setScaleType(ScaleType.XXX); 

4.EditText

1.ems:汉字显示宽度2. maxLenght : 最大字符3. hint: 提示4. textColorHint:提示的颜色5. inputType: 设置密码,设置数字(切换到数字键盘);6. digits : 只允许用户输入的字符7. singleLine : 单行模式8. imeOptions: 设置软键盘回车键的样式9.10. EditText独有的事件11. addTextChangeListener();12. 主要的方法13.14. onTextChanged(CharSequence 当前的字符串, int start, int before, int count) 

5.RadioButton 单选按钮

RadioButton必须放在一个RadioGroup中xml中禁止使用checked属性一般来说 使用RadioGroup的监听方法监听注意导包,RadioGroup用的自身的OnCheckedChangedListenerRadioButton用的CompoundsButton的OnCheckedChangeListener RadioButton可以设置该button字体上.下.左.右的图片RadioGroup中,如果给定了id号,那么使用R.id,如果没有,使用改元素的索引,从1开始

一个案例如下图

Android中的基础组件_第1张图片

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical" >    <RadioGroup        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_alignParentBottom="true"        android:orientation="horizontal" >        <RadioButton            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_weight="1"            android:button="@null"            android:drawableTop="@drawable/message_selected"            android:gravity="center"            android:text="回话" />        <RadioButton            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_weight="1"            android:button="@null"            android:drawableTop="@drawable/contacts_unselected"            android:gravity="center"            android:text="联系人" />        <RadioButton            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_weight="1"            android:button="@null"            android:drawableTop="@drawable/news_unselected"            android:gravity="center"            android:text="动态 " />    RadioGroup>RelativeLayout>

6.CheckBox多选按钮

同RadioButton 不需要放在一个RadioGroup中  是一个可以多选的按钮

更多相关文章

  1. Android RadioButton【单选按钮】的点击事件的两种方法
  2. 安卓课程十七 Button图文混排的按钮
  3. Android 建立文件夹、生成文件并写入文本文件内容
  4. Android多组件下Gradle统一配置
  5. Android 设置对话框中的确定按钮的 enabled 属性
  6. android 实现一个滚动文本
  7. 【Android 性能优化】布局渲染优化 ( GPU 过度绘制优化总结 | CP
  8. Android 使用富文本显示web上的内容
  9. Android实训案例(六)——四大组件之一BroadcastReceiver的基本使用

随机推荐

  1. Android Service生命周期
  2. 读书计划
  3. Android Fingerprint中的IPC(Binder)
  4. Android多国语言使用
  5. android中视频播放的处理
  6. ListView如何去掉无所谓的阴影
  7. 做了一个手机上的直播系统
  8. android sqlite数据库封装 实现crud
  9. android中文api(79)――Gallery
  10. Android学习2--项目文件列表简单分析