Android中冷门却超级有用的属性设置

送上开发中,解决了大问题的属性设置!

android:clipChildren=”false”是否可以超出父窗体

Defines whether a child is limited to draw inside of its bounds or not. This is useful with animations that scale the size of the children to more than 100% for instance. In such a case, this property should be set to false to allow the children to draw outside of their bounds. The default value of this property is true.

这个用处还是挺多的,有时候你需要让某一个超出父布局,但是超出了就没有绘制出来,这个属性就能解决这个问题!下面这个例子就是一个典型的运用。相关地址
Example

android:clipToPadding 是否剪切child的padding。

Defines whether the ViewGroup will clip its children and resize (but not clip) any EdgeEffect to its padding, if padding is not zero. This property is set to true by default.

这个最常用的就是ListView或者RecycleView等,默认顶部有个Padding,滑动的时候可以绘制到那一块区域汇中,不然上面总有一个留白的padding真的很丑的。

android:descendantFocusability

* blocksDescendants:阻断事件的传递
>The ViewGroup will block its descendants from receiving focus.
* afterDescendants:最后接受点击事件
>The ViewGroup will get focus only if none of its descendants want it.
* beforeDescendants:优先响应点击事件
>The ViewGroup will get focus before any of its descendants.

这里开始,都是一些Drawable相关的设置了!

android:foreground

如果你只知道background真的就太out了!,尤其是在5.0之后对RippleDrawable的支持!可以打造出比较酷炫的效果。

android:duplicateParentState:设置这个属性,用于接受父类指定的selector,而不是自己滴。

When this attribute is set to true, the view gets its drawable state (focused, pressed, etc.) from its direct parent rather than from itself.

自己写selector是不是总是很不爽啊?!!

在5.0之后,需要使用RippleDrawable的时候是不是要去建立两套selector?是不是很心塞很纠结,如果你颜色没有特别的要求,那么下面的这两个属性真的太爽歪歪了

  • ?attr/actionBarItemBackground //5.0上出来的就是一个圆圈的效果,超出View的大小。

  • ?attr/selectableItemBackground//5.0上出来的就是涟漪效果,不会超出View的大小。

目前开发中遇到的,使用的就是以上这些属性了!欢迎补充!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值