比如下面的代码:
<TextView android:id="@+id/item3"
android:text="费用(元)" android:width="100dip"
android:layout_width="wrap_content" android:layout_height="fill_parent"
/> 其中的
android:layout_width 与 android:width
有什么区别呢?
多谢!
<TextView android:id="@+id/item3"
android:text="费用(元)" android:width="100dip"
android:layout_width="wrap_content" android:layout_height="fill_parent"
/> 其中的
android:layout_width 与 android:width
有什么区别呢?
多谢!
android:width 这个是用来view的具体宽度的,以像素为单位。
px (pixels)像素
dip (device independent pixels)设备独立像素
sp (scaled pixels — best for text size)放大像素--对文本大小最好
pt (points)点
in (inches)英寸
mm (millimeters)毫米
android:width设置具体控件的横向大小 单位是像素
width:使视图刚好这么宽
这个好像不对哦。也可以这么用哦。
android:layout_width="200px"
android:layout_height="80px"
我测试了一下。如果两个属性同时赋值width和height无效(不起作用),而且与放置的顺序无关。
用下面这两个就足够了吧!@!
android:layout_width
android:layout_height
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.
只能提示显示layout_width可以有4种类型的值:fill_parent、match_parent、wrap_content、具体值。楼上几位说的只有两种值是不是跟Android SDK版本有关?
android:layout_width 其实是可以实现 android:width 的效果的,我觉得这应该是为什么在 android 实例中看不到有人用 android:width 的原因吧。
若还要讲讲两者的区别的话,那就是:
android:width 的值,一般是 "100dp" 这样的数值;
android:layout_width 的值,一般是"fill_parent","wrap_content","match_parent".当然,它也可以像前者一样,设置数值的.
带"layout"的属性是指整个控件而言的,是与父控件之间的关系,如 layout_gravity 在父控件中的对齐方式, layout_margin 是级别相同的控件之间的间隙等等;不带"layout" 的属性是指控件中文本的格式,如gravity是指文本的对齐方式等等,而其中文本的格式又受制约于它的控件在父控件中的属性.
layout_ 开头的xml属性都是查不到的?