专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Android

layout_width解决办法

发布时间:2010-05-30 10:54:40 文章来源:www.iduyao.cn 采编人员:星星草
layout_width
<TextView  
  android:layout_width="fill_parent" 
  android:layout_height="80px" 
/>
两个小问题:
1. 这2个属性layout_width和layout_height定义在哪啊?sdk中testview和它的父类view中都没找到啊
2. 这个宽度、高度只能用绝对值吗?因为我不确定ophone手机的屏幕宽度是不是一样的,我想用相对值,比如
  android:layout_width="fill_parent" 减去20个像素,怎么写啊,我写的一直报错

------解决方案--------------------
1. 你仔细找找,绝对有的
2. 这样写 android:layout_marginLeft="20dip" android:layout_marginRight="20dip"

等下再给你说
------解决方案--------------------
(1)sdk中找
(2)android:padding="20";
------解决方案--------------------
我在XML的定义里也没有找到,但是在R.attr找到了定义。

打开Android Help html,点击左上角的Class Index,在主界面的:
A B C D E F G H I J K L M N O P Q R S T U V W X Z 
中点击R
选择第四个R.attr(这个类我想是包括了所有的属性了)。
进入R.attr后,Ctrl + F查找layout_heigth和layaout_width就可以找到了。

public static final int layout_height 
Since: API Level 1 Specifies the basic height 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 height 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.

Constant Value Description
fill_parent -1 The view should be as big as its parent (minus padding).
wrap_content -2 The view should be only big enough to enclose its content (plus padding).


Constant Value: 16842997 (0x010100f5) 


public static final int layout_width 
Since: API Level 1 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.

Constant Value Description
fill_parent -1 The view should be as big as its parent (minus padding).
wrap_content -2 The view should be only big enough to enclose its content (plus padding).


Constant Value: 16842996 (0x010100f4)
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: