android 入门-android属性介绍

 
android:visibility="gone"  不保留view控件所占有的空间  隐藏
android:visibility="invisible" 保留了view控件所占有的空间 不可见
android:visibility="visible" 保留了view控件所占有的空间 可见
显隐
android:drawable 放一个drawable资源
android:state_pressed 是否按下,如一个按钮触摸或者点击。
android:state_focused 是否取得焦点,比如用户选择了一个文本框。
android:state_hovered 光标是否悬停,通常与focused state相同,它是4.0的新特性
android:state_selected 被选中,它与focus state并不完全一样,如一个list view 被选中的时候,它里面的各个子组件可能通过方向键,被选中了。
android:state_checkable 组件是否能被check。如:RadioButton是可以被check的。
android:state_checked 被checked了,如:一个RadioButton可以被check了。
android:state_enabled 能够接受触摸或者点击事件
android:state_activated 被激活(这个麻烦举个例子,不是特明白)
android:state_window_focused 应用程序是否在前台,当有通知栏被拉下来或者一个对话框弹出的时候应用程序就不在前台了
drawable属性
android:singleLine 设置单行显示。

如果和layout_width一起使用,当文本不能全部显示时,后面用“…”来表示。如

android:text="test_ singleLine "

android:singleLine="true"

android:layout_width="20dp"将只显示“t…”。如果不设置singleLine或者设置为false,文本将自动换行

android:ellipsize="start" 省略号在开头

android:ellipsize="middle" 省略号在中间

android:ellipsize="end" 省略号在结尾

android:ellipsize="marquee" 跑马灯显示
单行 省略
android:duplicateParentState
就是父控件响应点击事件,子View不响应点击事件,但是颜色要随着点击而发生变化。这样就用到了属性duplicateParentState。

”如果设置此属性,将直接从父容器中获取绘图状态(光标,按下等)。 注意仅仅是获取绘图状态,而没有获取事件,也就是你点一下LinearLayout时Button有被点击的效果,但是不执行点击事件“
duplicateParentState
android:layout_above="@id/xxx"  --将控件置于给定ID控件之上
android:layout_below="@id/xxx"  --将控件置于给定ID控件之下

android:layout_toLeftOf="@id/xxx"  --将控件的右边缘和给定ID控件的左边缘对齐
android:layout_toRightOf="@id/xxx"  --将控件的左边缘和给定ID控件的右边缘对齐

android:layout_alignLeft="@id/xxx"  --将控件的左边缘和给定ID控件的左边缘对齐
android:layout_alignTop="@id/xxx"  --将控件的上边缘和给定ID控件的上边缘对齐
android:layout_alignRight="@id/xxx"  --将控件的右边缘和给定ID控件的右边缘对齐
android:layout_alignBottom="@id/xxx"  --将控件的底边缘和给定ID控件的底边缘对齐
android:layout_alignParentLeft="true"  --将控件的左边缘和父控件的左边缘对齐
android:layout_alignParentTop="true"  --将控件的上边缘和父控件的上边缘对齐
android:layout_alignParentRight="true"  --将控件的右边缘和父控件的右边缘对齐
android:layout_alignParentBottom="true" --将控件的底边缘和父控件的底边缘对齐
android:layout_centerInParent="true"  --将控件置于父控件的中心位置
android:layout_centerHorizontal="true"  --将控件置于水平方向的中心位置
android:layout_centerVertical="true"  --将控件置于垂直方向的中心位置
RelativeLayout各个属性的含义
android:insetTop:图像距离上边的距离。

android:insetRight:图像距离右侧的距离。

android:insetBottom:图像距离底边的距离。

android:insetLeft:图像距离左侧的距离。
inset
原文地址:https://www.cnblogs.com/luquanmingren/p/4660931.html