【问题标题】:Why does "android create project", give a main.xml with fill_parent, not match_parent, if fill_parent is out of date?为什么“android 创建项目”,如果fill_parent 已过期,则给出一个带有fill_parent 的main.xml,而不是match_parent?
【发布时间】:2014-08-22 20:25:53
【问题描述】:

为什么android创建项目,如果fill_parent已经过期,给main.xml加上fill_parent,而不是match_parent?

我多次读到 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创建项目呢?

【问题讨论】:

    标签: android android-layout sdk


    【解决方案1】:

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

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

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-11
      • 2013-04-02
      • 1970-01-01
      • 1970-01-01
      • 2012-04-14
      • 1970-01-01
      • 2013-06-03
      • 2012-06-29
      相关资源
      最近更新 更多