TextView控件常用属性:
android:id–控件的id
android:layout_width–控件宽度
android:layout_height–控件高度
warp_content:包裹实际文本内容,文本有多宽,它就有多宽
match_parent:当前控件铺面父类容器(2.3API之后添加的属性值)
fill_parent:当前控件铺满父类容器
(2.3API之前添加的属性值)
android:text–文本内容
android:textSize–文本大小
androif:textColor–文本颜色
android:background–控件背景
EditView控件除拥有TextView的常用属性外还有以下属性:
android:hint–输入提示文本
android:inputType:输入文本类型(例如:纯数字)

layout下建立一个main_activity.xml文件"@id/textView1"    android:layout_width="warp_content"    androidLlayout_height="warp_content"    android:text="姓名"    android:textSize="28sp"    android:textColor="#000000"    />
<EditText    android:text="abcd"    android:hint="请输入你的姓名"    android:id="@+id/editText1"    android:layout_width="match_parent"    android:layout_weight="warp_content">EditText>

src下建立MainActivity.java文件

public class MainActivity extends Activity{    @Override    protected void onCreate(Bundle savedInstanceState){    super.onCreate(savedInseanceState);    //将布局xml文件引入到activity中    setContenView(R.layout.main_activity);    }}
android:inputType="textPassword" //设置输入格式为密码格android:inputType="phone"  //设置输入格式为拨号键盘

ImageView控件用于显示图片
常用属性:

//ImageView的内容图像android:src="@drawable/ic_launcher"//ImageView背景图片android:background:"@drawable/ic_launcher"//设置ImageView的颜色android:background="#00ff00"

Button(按钮)与ImageButton(图片按钮)

Button有text属性,ImageButton没有。
ImageButton有src属性,Button没有。
.xml文件访问Strings.xml中的资源:
strings.xml

登陆

main.xml访问

<Buttonandroid:text="@string/button_name"/>/>

更多相关文章

  1. 【Android】第7章(2)--布局控件常用的公共属性
  2. Android 实现多行文本跑马灯效果
  3. Android 动态设置TextView的drawableLeft等属性
  4. android:inputType 属性及其支持的取值
  5. Android UI系列-----ImageView的scaleType属性
  6. Android 中如何获取editText文本信息

随机推荐

  1. sql 查询慢的原因分析
  2. 模糊查询的通用存储过程
  3. SQL Server 中查看SQL句子执行所用的时间
  4. MySql 安装时的1045错误
  5. 数据库Left join , Right Join, Inner Jo
  6. SQL Server 排序函数 ROW_NUMBER和RANK
  7. sql server 常用的几个数据类型
  8. SQLServer EVENTDATA()函数来获取DDL 触
  9. SQLServer Top语句参数化方法
  10. SQL server 随机数函数