public enum ResourceVisibility extends java.lang.Enum<ResourceVisibility>
The below is the description of how AAPT2 understands resource visibility:
Public visibility.
A resource can be marked as public by adding the public element to a values XML file:
<public name="my_public_string" type="string"/>.
These elements are usually defined in the public.xml file inside the res/values directory.
Private visibility.
Sometimes a libraries can have a great number of resources and it might be confusing or
tiresome to find the correct one when writing the Java or Kotlin code. In order to restrict the
resources visible from the source code, one can list the only resources they want to be visible
by using the java-symbol element:
<java-symbol name="my_visible_string" type="string/>.
These elements are usually defined in the symbols.xml file inside the res/values directory. The name private comes from these resources being present in the
private R.java along with public resources.
Private XML only visibility.
All resources that were not marked as public or private have the default visibility. They are not placed in either public nor private R classes
and are only accessible from other XML resources within that library/module.
Without the package for the private R.java specified, only the public R.java will be generated and it will contain all resources (ones marked as public, java-symbol and those not marked as either).
Additionally in the Gradle plugin we have the last enum value, UNDEFINED. It
represents a case where the visibility was not defined at all. This should be only used in the
case when we are not generating the public and private R class.
| Enum Constant and Description |
|---|
PRIVATE |
PRIVATE_XML_ONLY |
PUBLIC |
UNDEFINED |
| Modifier and Type | Method and Description |
|---|---|
static ResourceVisibility |
getEnum(java.lang.String qualifier) |
java.lang.String |
getName() |
static ResourceVisibility |
max(ResourceVisibility v1,
ResourceVisibility v2) |
static ResourceVisibility |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static ResourceVisibility[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final ResourceVisibility PRIVATE_XML_ONLY
public static final ResourceVisibility PRIVATE
public static final ResourceVisibility PUBLIC
public static final ResourceVisibility UNDEFINED
public static ResourceVisibility[] values()
for (ResourceVisibility c : ResourceVisibility.values()) System.out.println(c);
public static ResourceVisibility valueOf(java.lang.String name)
name - the name of the enum constant to be returned.java.lang.IllegalArgumentException - if this enum type has no constant with the specified namejava.lang.NullPointerException - if the argument is nullpublic java.lang.String getName()
public static ResourceVisibility getEnum(@NonNull java.lang.String qualifier)
public static ResourceVisibility max(@NonNull ResourceVisibility v1, @NonNull ResourceVisibility v2)