android - 如果 fill_parent 已过期,为什么 "android create project"会给出一个带有 fill_parent 而不是 match_parent 的 main.xml?

标签 android android-layout sdk

如果 fill_parent 已过期,为什么 android 创建项目,给一个带有 fill_parent 而不是 match_parent 的 main.xml?

我读过很多次,您应该使用 match_parent,而不是 fill_parent。

但是我在执行 android create project 命令时看到了

c:\androidsdktools\sdk\platform-tools>android create project --activity acto --p
ackage a.b.c --target "android-20" --path c:\bleeeeh

查看它生成的 main.xml

我看到使用了 fill_parent,而不是 match_parent。

但这是我下载的最新的android sdk。

c:\bleeeeh\res\layout>type main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout ..........
..........
    android:layout_width="fill_parent"
........
</LinearLayout>

c:\bleeeeh\res\layout>

只是为了表明这是撰写本文时最新的 android sdk.. 2014 年 7 月下载。Android-20

c:\androidsdktools\sdk\platforms>dir /ad
....
25/07/2014  09:56 AM    <DIR>          android-20
31/07/2014  10:32 PM    <DIR>          android-L
....
c:\androidsdktools\sdk\platforms>

虽然我什至从 2012 年就看到帖子说不应该使用 fill_parent,但应该使用 match_parent。

那么,为什么android在main.xml中使用fill_parent来创建项目呢?

最佳答案

So, why is android create project using fill_parent in main.xml?

首先,fill_parent 工作正常。虽然 match_parent 是官方首选值,但它映射到与 fill_parent 相同的行为。

其次,android create project使用的项目模板对于Android工具团队来说并不是特别高的优先级,很大程度上是因为android与 Android Studio 和 Eclipse 相比,create project 工具本身对于 Android 工具团队来说并不是特别重要的优先级。我预计 android create project 将在适当的时候完全停止或被其他东西取代。

如果您愿意,欢迎您修改布局文件以使用 match_parent

请记住,android create project 旨在创建使用 Ant 构建工具构建的项目,而对 Ant 的支持正在迅速消失。如果您不想,可以不必使用 IDE,但您应该考虑在不久之后迁移到 Gradle for Android。

关于android - 如果 fill_parent 已过期,为什么 "android create project"会给出一个带有 fill_parent 而不是 match_parent 的 main.xml?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25455066/

相关文章:

Android通知高度和宽度

android - 如何使用媒体播放器播放和暂停音频?

android - 如何动态改变形状颜色?

android - 如何自动更新 Android Studio?

Android:图形shape.intersects方法。 android中有模拟吗?

android - Textview环绕 View

android - 约束布局垂直对齐中心 - 两个 subview

c++ - 帮助!错误 C2040 : 'HWINEVENTHOOK' : 'DWORD' differs in levels of indirection from 'HWINEVENTHOOK__ *'

javascript - Opera SDK开发

java - 将纪元时间转换为日期字符串