Android-何时以及出于什么目的,我们在android xml文件中使用以下前缀? [英] Android - When and for which purpose we use the following prefixes in android xml file?

查看:100
本文介绍了Android-何时以及出于什么目的,我们在android xml文件中使用以下前缀?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是android开发的新手,对以下前缀感到困惑:

I am new to android development and confused about the following prefixes:

  1. xmlns:android
  2. xmlns:app
  3. xmlns:tools
  4. android:something
  5. app:something
  6. tool:something
  1. xmlns:android
  2. xmlns:app
  3. xmlns:tools
  4. android:something
  5. app:something
  6. tool:something

我对它们感到困惑,因为有时我会使用一个,而android studio会将其标记为红色下划线,这意味着我应该使用另一个下划线,而有时我会使用另一个,则android studio将其标记为红色线条,这意味着我应该使用其他等等,这让我感到困惑.甚至在某些情况下,我注意到我们也不允许使用其中的任何一个,例如style属性,layout属性等.

I am confused about them because sometimes I use one, and android studio marks it as red underline which means i should use another one, and when sometimes i use another one android studio marks it with red line which means i should use the other one and so on, which makes me confused. And even in some cases i noticed that we are not allowed to use any one of them for example style attribute, layout attribute etc.

每个代表什么?

哪个用途用于哪个目的?

哪个是父母,孩子和子孩子,或者我对这个逻辑有误?

那里比他们还远吗?如果是,请共享资源或链接

为什么有时我们不使用这些前缀,例如stylelayout等?

我想了解它们以易于理解和正确的方式使用它们. 非常感谢!!!

I want to know about them to use them with understandable and proper way. Thank you very much !!!

推荐答案

正如Henry所说,这些被称为命名空间.

as Henry said, these are called namespaces.

tools名称空间用于更改组件,而无需在运行时应用.在设计和测试不同的布局或组件时非常有用,而不会在运行应用程序时影响代码.

the tools namespace is used to make changes to components without it being applied at runtime. it is useful for designing and testing different layouts or components without it affecting your code when you run the app.

android名称空间通常用于android属性,这意味着它来自Android SDK本身.

the android namespace is usually used for an android attribute, meaning that it comes from the Android SDK itself.

app名称空间用于支持库组件,因此它适用于各种不同版本的android.

the app namespace is used for support library components, so that it works for various different versions of android.

xmlns只是一个命名空间,指定它是一个xml文档,这些名称用于更改xml文档本身.

xmlns is simply a namespace specifying that it is an xml document, these are used for making changes to the xml document itself.

这篇关于Android-何时以及出于什么目的,我们在android xml文件中使用以下前缀?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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