• android xml布局文件中tools:layout的作用


    摘要 用最新版本的adt 创建一个基于master/detail flow 模版的app的时候,生成的 activity_item_list.xml 文件中有一个tools:layout属性: fragment xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"

    用最新版本的adt 创建一个基于master/detail flow 模版的app的时候,生成的activity_item_list.xml 文件中有一个tools:layout属性:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/item_list"
        android:name="com.example.fragmenttwopanel.ItemListFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp"
        tools:context=".ItemListActivity"
        tools:layout="@android:layout/list_content" />

    一开始不明白,后来删掉这个属性之后发现会出现一个提示:

    pick preview layout from the "Fragment Layout" context menu

    原来tools:layout仅仅是告诉编辑器,Fragment在程序预览的时候该显示成什么样,并不会对apk产生实际作用,是为开发者设计的。

    一般来说被xmlns:tools="http://schemas.android.com/tools" 声明的tools作为前缀的属性都不会被编译进去。这个跟上面代码中tools:context是一样的。

  • 相关阅读:
    iOS学习05C语言函数
    iOS学习04C语言数组
    iOS学习03C语言循环结构
    iOS学习02C语言分支结构
    iOS学习01C语言数据类型
    Objective-C学习——中文URL编码和解码
    Objective-c 字面量
    SDWebImage
    mac的svn之cornerstone简易教程
    javascript 和oc交互
  • 原文地址:https://www.cnblogs.com/xgjblog/p/4196393.html
Copyright © 2020-2023  润新知