工具的目的是什么:从向导创建DrawerLayout(带有NavigationView)时? [英] What's the purpose of tools:openDrawer="start" when creating a DrawerLayout (with NavigationView) from the wizard?

本文介绍了工具的目的是什么:从向导创建DrawerLayout(带有NavigationView)时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android Studio中使用导航抽屉创建活动会导致该活动显示在XML代码中

Creating an activity with navigation drawer in Android Studio causes this to be shown in the XML code:

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

如果我删除了tools:openDrawer="start",则在布局预览中,导航抽屉将关闭而不是打开.

If I remove the tools:openDrawer="start", on the layout preview, the navigation drawer will be closed instead of open.

我认为这是一个替换属性,类似于android:text,可以用tools:text替换以在布局预览中放置一些占位符文本.但是,当我将其更改为android:openDrawerapp:openDrawer时,无法编译该应用程序,因为它们是未知属性.

I thought this was a replacement attribute, similar to android:text that can be replaced with tools:text to put some placeholder text in the layout preview. But when I change it to android:openDrawer or app:openDrawer, the app can't be compiled because they are unknown attributes.

所以我想知道tools:openDrawer的工作方式,以及它是否在任何地方都有记载.

So I wonder how tools:openDrawer works, and whether it is documented anywhere.

推荐答案

Android具有专用于工具的XML名称空间,以便能够 将信息记录在XML文件中,并去除该信息 打包应用程序以使没有运行时或 下载大小的罚款.命名空间URI是 http://schemas.android.com/tools ,通常绑定到以下工具: 前缀:

Android has a dedicated XML namespace intended for tools to be able to record information in XML files, and have that information stripped when the application is packaged such that there is no runtime or download size penalty. The namespace URI is http://schemas.android.com/tools and is usually bound to the tools: prefix:

这意味着tools属性由IDE使用,而未在代码功能中使用.

This means that tools attribute is used by the IDE and not used in the code functionality.

我仍在尝试查找所有tools属性的完整文档.我在任何地方都找不到openDrawer属性.但是以下是有关tools的出色文档:

I am still trying to find the complete documentation of all tools attributes. I can't find out the openDrawer attribute anywhere. But the following are great documentation on tools:

http://tools.android.com/tech-docs/tools-attributes
http://tools.android.com/tips/layout-designtime-attribute

更新

现在可以在此处获得有关所有tools属性的完整文档. a>.

Now a complete documentation of all tools attribute is available here.

这篇关于工具的目的是什么:从向导创建DrawerLayout(带有NavigationView)时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆