1.宽/高
android:layout_width
android:layout_height
// 取值
match_parent //匹配父控件
wrap_content //自适应,根据内容

如果指定宽度,请用单位dp

2.控件在父控件中的对齐位置
android:layout_gravity

3.控件中文本的对齐方式
android:gravity

4.控件内元素的排列方式
android:orientation

取值:
horizontal 水平
vertical 垂直

5.文字大小
android:textSize
单位sp

6.文字颜色
android:textColor

7.重要属性:
android:layout_weight
指定控件在屏幕中占比权重

8.EditText:
android:hint //指定提示性文字
android:maxLines //指定最大行数
android:text //指定文本

java获取文本:
EditText.getText().toString()

9.分割线:
android:divider="#ffffff"
android:showDividers="middle"

10.ImageView指定图片路径:
xml:
android:src="@mipmap/ic_launcher"
java:
ImageView.setImageResource(R.drawable.c);

11.ProgressBar隐藏显示:
xml:
android:visibility="gone"
java:
ProgressBar.setVisibility(View.GONE);

取值:
gone 不可见,也不占位
visible:可见
invisible:不可见,但占位

visibility属性为所有android控件均有的属性
通过ProgressBar.getVisibility() == View.GONE来判断控件是否隐藏来决定进一步动作

12.ProgressBar:
loading样式:style="?android:attr/progressBarStyle"
进度条样式:style="?android:attr/progressBarStyleHorizontal"

进度条样式:
设置进度条最大值: android:max="100"

java中动态设置大小:
int progress = ProgressBar.getProgress();
progress = progress + 10;
ProgressBar.setProgress(progress);

13.AlertDialog提示框:
AlertDialog的构造方法全部是protected,所以不能通过new来创建,需要借助AlertDialog.Build
java代码:
AlertDialog.Builder dialog = new AlertDialog.Builder(MainActivity.this);
dialog.setIcon(R.drawable.zh); // 设置图标
dialog.setTitle("提示"); //对话框标题
dialog.setMessage("这就是提示"); //对话框内容
dialog.setCancelable(false); //防止后退按钮关闭AlertDialog

// Yes按钮
dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(MainActivity.this, "ok", Toast.LENGTH_LONG).show();
}
});
// No按钮
dialog.setNegativeButton("我知道了,关闭", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(MainActivity.this, "canal", Toast.LENGTH_LONG).show();
}
});
// 显示对话框
dialog.show();

14.按钮判断:
v.getId() == R.id.button

15.ProgressDialog:loading样式的对话框
java:
ProgressDialog progressDialog = new ProgressDialog(MainActivity.this);
progressDialog.setIcon(R.drawable.alert);
progressDialog.setTitle("提示");
progressDialog.setMessage("正在加载中...");
progressDialog.setCancelable(true);
progressDialog.show();

16.margin属性:
android:layout_margin 距父控件上下左右的边距
android:layout_marginTop 距父控件上边
android:layout_marginLeft 距父控件左边
android:layout_marginRight 距父控件右边
android:layout_marginBottom 距父控件下边

17.padding属性:
android:padding 控件上下左右的填充
android:paddingLeft 左边填充
android:paddingRight 右边填充
android:paddingTop 上边填充
android:paddingBottom 下边填充

Android控件常见属性的更多相关文章

  1. android控件的属性

    android控件的属性 本节描述android空间的位置,内容等相关属性及属性的含义 第一类:属性值为true或false android:layout_centerHrizontal 水平居中 ( ...

  2. Android入门(六):Android控件布局属性全解

    第一类:属性值为true或falseandroid:layout_centerHrizontal 水平居中 (Hrizontal表示水平)android:layout_centerVertical 垂 ...

  3. iOS- <项目笔记>UI控件常见属性总结

    1.UIView // 如果userInteractionEnabled=NO,不能跟用户交互 @property(nonatomic,getter=isUserInteractionEnabled) ...

  4. UIAutomator定位Android控件的方法

    UIAutomator各种控件定位的方法. 1. 背景 使用SDK自带的NotePad应用,尝试去获得在NotesList那个Activity里的Menu Options上面的那个Add note菜单 ...

  5. 【转】UIAutomator定位Android控件的方法实践和建议(Appium姊妹篇)

    原文地址:http://blog.csdn.net/zhubaitian/article/details/39777951 在本人之前的一篇文章<<Appium基于安卓的各种FindEle ...

  6. UIAutomator定位Android控件的方法实践和建议(Appium姊妹篇)

    在本人之前的一篇文章<<Appium基于安卓的各种FindElement的控件定位方法实践和建议>>第二章节谈到Appium可以通过使用UIAutomator的方法去定位And ...

  7. Android中常用控件及属性

    在之前的博客为大家带来了很多关于Android和jsp的介绍,本篇将为大家带来,关于Andriod中常用控件及属性的使用方法,目的方便大家遗忘时,及时复习参考.好了废话不多讲,现在开始我们本篇内容的介 ...

  8. Android - 控件android:ems属性

    Android - 控件android:ems属性http://blog.csdn.net/caroline_wendy/article/details/41684255?utm_source=tui ...

  9. 关于Android控件EditText的属性InputType的一些经验,java组合多个参数

    关于Android控件EditText的属性InputType的一些经验 2013-11-14 15:08:02|  分类: 默认分类|举报|字号 订阅       1.InputType属性在代码中 ...

随机推荐

  1. 【ZOJ4061】Magic Multiplication(构造)

    题意:定义一个新运算为两个数A,B上每一位相乘,然后顺次接在一起,现在给定结果C和原来两个数字的长度,要求恢复成原来的数字A,B 若有多解输出A字典序最小的,A相同输出B字典序最小的,无解输出Impo ...

  2. linux free 命令 ,讲解得比较好

    解释一下Linux上free命令的输出. 下面是free的运行结果,一共有4行.为了方便说明,我加上了列号.这样可以把free的输出看成一个二维数组FO(Free Output).例如: FO[2][ ...

  3. aiohttp/asyncio 多次请求

    #!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = "Daniel Altiparmak (sixfinger78@gmai ...

  4. $.getJSON无法对外部变量进行赋值的问题

    如下,即可将d中的值赋给外部变量 //把ajax的异步设置成同步,防止$.getJSON无法对外部变量进行赋值,必须在$.getJson前面 $.ajaxSetup({async:false}); $ ...

  5. Selenium2+python自动化9-CSS定位语法【转载】

    前言 大部分人在使用selenium定位元素时,用的是xpath定位,因为xpath基本能解决定位的需求.css定位往往被忽略掉了,其实css定位也有它的价值,css定位更快,语法更简洁.这一篇css ...

  6. Redis设置记录

    首先大前提是,这个redis使用的外网端口,需要在防火墙或者安全组中打开 正常在redis配置文件里有个bind,这个默认是127.0.0.1,如果不修改,就是内网可以访问. 这里有个点需要提一下,就 ...

  7. IE常见兼容问题

    图片有边框 CSS 增加 border:0; border,在IE 模式下不算在宽度内;

  8. HDU 1754.I Hate It-完全版线段树(单点替换、区间最值)

    HDU1754.I Hate It 直接模板就可以了 代码: //B #include<iostream> #include<cstdio> #include<cstri ...

  9. Codeforces Round #270 A. Design Tutorial: Learn from Math【数论/埃氏筛法】

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  10. Educational Codeforces Round 33 (Rated for Div. 2) A. Chess For Three【模拟/逻辑推理】

    A. Chess For Three time limit per test 1 second memory limit per test 256 megabytes input standard i ...