您的位置:首页 > 移动开发 > Android开发

android:layout_gravity 和 android:gravity

2013-10-31 10:43 183 查看
 android:layout_gravity和 android:gravity的区别,android:gravity是对元素本身说的,元素本身的文本显示在什么地方靠着

换个属性设置,不过不设置默认是在左侧的。android:layout_gravity是相对与它的父元素说的,说明元素显示在父元素的什么位置。

比如说button, android:layout_gravity 表示按钮在界面上的位置。 android:gravity表示button上的字在按钮上的位置。

1.

public static final int width

Makes the TextView be exactly this many pixels wide. You could get the same effect by specifying this number in the layout parameters.

public static final int layout_width

Specifies the basic width of the view. This is a required attribute for any view inside of a containing layout manager. Its value may be a dimension (such as "12dip") for a constant width or one of the special constants.

May be a dimension value, which is a floating point number appended with a unit such as "
14.5sp
". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), mm (millimeters).

This may also be a reference to a resource (in the form "
@[package:]type:name
") or theme attribute (in the form "
?[package:][type:]name
") containing a value of this type.

May be one of the following constant values.

ConstantValueDescription
fill_parent
-1The view should be as big as its parent (minus padding). This constant is deprecated starting from API Level 8 and is replaced by
match_parent
.
match_parent
-1The view should be as big as its parent (minus padding). Introduced in API Level 8.
wrap_content
-2The view should be only big enough to enclose its content (plus padding).
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: