关于"match_parent"这个xml的布局设定值

android:layout_width="match_parent"

android:layout_height="match_parent"


"match_parent" 这个设置值 Since: API Level 8

public static final int MATCH_PARENT
Since: API Level 8

Special value for the height or width requested by a View. MATCH_PARENT means that the view wants to be as big as its parent, minus the parent's padding, if any. Introduced in API Level 8.

Constant Value: -1 (0xffffffff)

因此当你使用sdk2.2以下来编译时,编译会通不过!


再来看看下面这个

public static final int FILL_PARENT
Since: API Level 1

Special value for the height or width requested by a View. FILL_PARENT means that the view wants to be as big as its parent, minus the parent's padding, if any.This value is deprecated starting in API Level 8 and replaced byMATCH_PARENT.

Constant Value: -1 (0xffffffff)

也就是说,当你使用2.2以上的sdk编译成的app运行在2.2以下系统的手机上, "match_parent"的使用就赞同于使用了“full_parent”,因此这个值的设置对app的多os版本运行是没有影响的!!!



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
使用 XML 编写登录界面,首先需要使用布局标签(如 `LinearLayout`、`RelativeLayout` 等)来设定界面的布局方式。 然后,使用视图标签(如 `TextView`、`EditText`、`Button` 等)来添加登录界面所需的元素,如用户名和密码输入框、登录按钮等。 下面是一个示例 XML 代码,它定义了一个登录界面,包含用户名、密码输入框和登录按钮: ```xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:gravity="center_horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/username" /> <EditText android:id="@+id/username" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="text" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/password" /> <EditText android:id="@+id/password" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="textPassword" /> <Button android:id="@+id/login_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/login" /> </LinearLayout> ``` 该登录界面使用 `LinearLayout` 布局,其中包含了文本标签(`TextView`)和输入框(`EditText`)作为用户名和密码的输入元素,还有一个登录按

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值