- 構文:
<property android:name="string" android:resource="resource specification" android:value="string" />
- 上位の要素:
<activity>
<activity-alias>
<application>
<provider>
<receiver>
<service>
- 説明:
- 親コンポーネントに提供可能な任意の追加データアイテムの名前と値のペア。コンポーネント要素には任意の数の
<property>
サブ要素を含めることができます。有効な値には、PackageManager
クラスで定義されたプロパティ定数、WindowProperties
などのクラスで定義されたPackageManager.Property
タグ、アドホックで定義された任意の定数が含まれます。PackageManager.getProperty()
メソッドを使用して個別に値を取得します。通常の値を指定する場合は
android:value
属性を使用します。リソース ID はandroid:resource
属性で指定します。android:value
とandroid:resource
の両方を指定することはできません。たとえば、以下のコードは、
@string/kangaroo
リソースにどのような値が格納されていても、名前としてzoo
に割り当てます。<property android:name="zoo" android:value=”@string/kangaroo” />
ただし、以下のコードは、リソースに格納されている値ではなく、リソースの数値 ID を
zoo
に割り当てます。<property android:name="zoo" android:resource=”@string/kangaroo” />
- 属性:
android:name
- プロパティの名前。兄弟である複数の
<property>
タグの名前が同じであると、解析エラーが発生します。 android:resource
- リソースへの参照。リソースの ID はプロパティに割り当てられた値です。ID は、
PackageManager.Property.getResourceId()
でプロパティから取得できます。 android:value
- プロパティに割り当てられた値。以下の表に、value 属性の有効なデータ型とアクセサ メソッドを示します。
データ型 PackageManager.Property アクセサ 文字列: 文字をエスケープするには、2 つのバックスラッシュ(\\)を使用する(Unicode 文字の場合、「 \\n
」や「\\uxxxxx
」など)getString()
整数: 100
などgetInteger()
ブール値: true
またはfalse
getBoolean()
カラー: #rgb
、#argb
、#rrggbb
、#aarrggbb
の形式getInteger()
浮動小数点数: 1.23
などgetFloat()
注:
<property>
タグにandroid:value
属性とandroid:resource
属性の両方を含めることはできません。その場合は、android:resource
の使用をおすすめします。- 導入時の API レベル:
- API レベル 31
<プロパティ>
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-07-27 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-07-27 UTC。"],[],[],null,["# <property\u003e\n\nsyntax:\n:\n\n ```xml\n \u003cproperty android:name=\"string\"\n android:resource=\"resource specification\"\n android:value=\"string\" /\u003e\n ```\n\ncontained in:\n: [\u003cactivity\u003e](/guide/topics/manifest/activity-element)\n\n [\u003cactivity-alias\u003e](/guide/topics/manifest/activity-alias-element)\n\n [\u003capplication\u003e](/guide/topics/manifest/application-element)\n\n [\u003cprovider\u003e](/guide/topics/manifest/provider-element)\n\n [\u003creceiver\u003e](/guide/topics/manifest/receiver-element)\n\n [\u003cservice\u003e](/guide/topics/manifest/service-element)\n\ndescription:\n: A name-value pair for an item of additional, arbitrary data that can be supplied to the\n parent component. A component element can contain any number of `\u003cproperty\u003e` subelements. Valid names\n include any of the [property constants](/reference/android/content/pm/PackageManager#constants_1) defined in\n the [PackageManager](/reference/android/content/pm/PackageManager) class,\n [PackageManager.Property](/reference/android/content/pm/PackageManager.Property) tags defined\n in classes such as [WindowProperties](/reference/kotlin/androidx/window/WindowProperties), and arbitrary constants defined ad hoc. Obtain values individually using the\n [PackageManager.getProperty()](/reference/android/content/pm/PackageManager#getProperty(java.lang.String,%20java.lang.String)) method.\n\n Specify ordinary values with the [android:value](/guide/topics/manifest/property-element#val)`\n ` attribute. Specify resource IDs with the\n [android:resource](/guide/topics/manifest/property-element#rsrc) attribute. Specifying\n both `android:value` and `android:resource` is invalid.\n\n\n For example, the following code assigns whatever value is stored in the `@string/kangaroo` resource to\n the `zoo` name:\n\n\n ```xml\n \u003cproperty android:name=\"zoo\" android:value=”@string/kangaroo” /\u003e\n ```\n\n\n The code here, however, assigns the numeric ID of the resource, not the value stored in the resource, to\n `zoo`:\n\n\n ```xml\n \u003cproperty android:name=\"zoo\" android:resource=”@string/kangaroo” /\u003e\n ```\n\nattributes:\n:\n\n `android:name`\n : The name of the property. A parsing error results if multiple, sibling `\u003cproperty\u003e` tags have the\n same name.\n\n `android:resource`\n : A reference to a resource. The ID of the resource is the value assigned to the property. The ID can be retrieved\n from the property by\n [PackageManager.Property.getResourceId()](/reference/android/content/pm/PackageManager.Property#getResourceId()).\n\n `android:value`\n : A value assigned to the property. The following table lists valid data types and accessor methods for the value\n attribute: \n\n\n | Type | PackageManager.Property accessor |\n |-----------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------|\n | String: Use double backslashes (\\\\\\\\) to escape characters; for example, `\\\\n` and `\\\\uxxxxx` for a Unicode character | [getString()](/reference/android/content/pm/PackageManager.Property#getString()) |\n | Integer: For example, `100` | [getInteger()](/reference/android/content/pm/PackageManager.Property#getInteger()) |\n | Boolean: Either `true` or `false` | [getBoolean()](/reference/android/content/pm/PackageManager.Property#getBoolean()) |\n | Color: In the form `#rgb`, `#argb`, `#rrggbb`, or `#aarrggbb` | [getInteger()](/reference/android/content/pm/PackageManager.Property#getInteger()) |\n | Float: For example, `1.23` | [getFloat()](/reference/android/content/pm/PackageManager.Property#getFloat()) |\n\n\nintroduced in:\n: API Level 31"]]