TextView 的gravity属性


一、先看api

android:gravity

Specifies how to align the text by the view's x- and/or y-axis when the text is smaller than the view.

Must be one or more (separated by '|') of the following constant values.

ConstantValueDescription
top0x30Push object to the top of its container, not changing its size.
bottom0x50Push object to the bottom of its container, not changing its size.
left0x03Push object to the left of its container, not changing its size.
right0x05Push object to the right of its container, not changing its size.
center_vertical0x10Place object in the vertical center of its container, not changing its size.
fill_vertical0x70Grow the vertical size of the object if needed so it completely fills its container.
center_horizontal0x01Place object in the horizontal center of its container, not changing its size.
fill_horizontal0x07Grow the horizontal size of the object if needed so it completely fills its container.
center0x11Place the object in the center of its container in both the vertical and horizontal axis, not changing its size.
fill0x77Grow the horizontal and vertical size of the object if needed so it completely fills its container.
clip_vertical0x80Additional option that can be set to have the top and/or bottom edges of the child clipped to its container's bounds. The clip will be based on the vertical gravity: a top gravity will clip the bottom edge, a bottom gravity will clip the top edge, and neither will clip both edges.
clip_horizontal0x08Additional option that can be set to have the left and/or right edges of the child clipped to its container's bounds. The clip will be based on the horizontal gravity: a left gravity will clip the right edge, a right gravity will clip the left edge, and neither will clip both edges.
start0x00800003Push object to the beginning of its container, not changing its size.
end0x00800005Push object to the end of its container, not changing its size.

This corresponds to the global attribute resource symbol gravity.

Related Methods

二、再看stackoverflow(仅仅我的理解,未验证)

clip_vertical

意思是剪掉TextView的上部或者下部,来适应TextView的父控件。

这里是TextView的上/下部,不是TextView中的文字。


参考:

1. http://developer.android.com/reference/android/widget/TextView.html#attr_android:gravity

2. http://stackoverflow.com/questions/4198073/what-is-androidlayout-gravity-clip-vertical-exactly

3. http://www.iciba.com/clip

4. http://www.iciba.com/squish

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值