Android XML属性中的星号(*)[重复]

时间:2022-02-08 22:24:24

This question already has an answer here:

这个问题在这里已有答案:

Can anyone explain the asterisk means in Android XML attributes?

任何人都可以解释星号在Android XML属性中的含义吗?

<style name="DocumentsTheme" parent="@style/DialogWhenReallyLarge">
    <item name="android:actionBarTheme">@*android:style/ThemeOverlay.Material.Dark.ActionBar</item>
    <item name="*android:windowFixedWidthMajor">@null</item>
</style>

1 个解决方案

#1


The * allows you to access private resources. Private resources are private for a reason as their name could change in the future as part of a firmware or skin update.

*允许您访问私人资源。私有资源是私有的,因为他们的名字将来可能会作为固件或皮肤更新的一部分而改变。

It's not a good idea to use these resources unless you're working in an environment where you know these resources won't change and break your app in the future.

使用这些资源并不是一个好主意,除非您在一个环境中工作,在这种环境中您知道这些资源将来不会改变并破坏您的应用程序。

In your example, the private resources are being referenced by a system app which is where you'll most commonly see this * referencing used.

在您的示例中,系统应用程序正在引用私有资源,您最常见的是使用此引用。

@android:id refers to the public system member called "id"
@id refers to one that you've created
@+id says to create one called "id" (and what to set it to)
@*android:id refers to a private system member

#1


The * allows you to access private resources. Private resources are private for a reason as their name could change in the future as part of a firmware or skin update.

*允许您访问私人资源。私有资源是私有的,因为他们的名字将来可能会作为固件或皮肤更新的一部分而改变。

It's not a good idea to use these resources unless you're working in an environment where you know these resources won't change and break your app in the future.

使用这些资源并不是一个好主意,除非您在一个环境中工作,在这种环境中您知道这些资源将来不会改变并破坏您的应用程序。

In your example, the private resources are being referenced by a system app which is where you'll most commonly see this * referencing used.

在您的示例中,系统应用程序正在引用私有资源,您最常见的是使用此引用。

@android:id refers to the public system member called "id"
@id refers to one that you've created
@+id says to create one called "id" (and what to set it to)
@*android:id refers to a private system member