Karmaşık XML kaynaklarını satır içi
Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
Belirli kaynak türleri, XML dosyalarıyla temsil edilen birden çok karmaşık kaynağın bileşimidir.
Örnek olarak, bir vektörü kapsayan çizilebilir bir kaynak olan animasyonlu bir çekilebilir vektör gösterilebilir.
çizim ve animasyon. Bu,
takip ediliyor
örnekler.
res/drawable/avd.xml
-
<?xml version="1.0" encoding="utf-8"?>
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/vectordrawable" >
<target
android:name="rotationGroup"
android:animation="@anim/rotation" />
</animated-vector>
res/drawable/vectordrawable.xml
-
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="64dp"
android:width="64dp"
android:viewportHeight="600"
android:viewportWidth="600" >
<group
android:name="rotationGroup"
android:pivotX="300.0"
android:pivotY="300.0"
android:rotation="45.0" >
<path
android:fillColor="#000000"
android:pathData="M300,70 l 0,-70 70,70 0,0 -70,70z" />
</group>
</vector>
res/anim/rotation.xml
-
<?xml version="1.0" encoding="utf-8"?>
<objectAnimator xmlns:android="http://schemas.android.com/apk/android"
android:duration="6000"
android:propertyName="rotation"
android:valueFrom="0"
android:valueTo="360" />
Vektör ve animasyonlar başka bir yerde yeniden kullanılırsa bu,
animasyonlu çekilebilir vektör. Ancak bu dosyalar yalnızca bu çizim
daha kompakt bir yönteme sahip olursunuz.
AAPT'nin satır içi kaynak biçimini kullanarak üç kaynağı da aynı XML dosyasında tanımlayabilirsiniz.
aşağıdaki örnekte gösterilmiştir.
Çekilebilir animasyonlu bir vektör için dosyayı res/drawable/
altına yerleştirin.
res/drawable/avd.xml
-
<?xml version="1.0" encoding="utf-8"?>
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt" >
<aapt:attr name="android:drawable" >
<vector
android:height="64dp"
android:width="64dp"
android:viewportHeight="600"
android:viewportWidth="600" >
<group
android:name="rotationGroup"
android:pivotX="300.0"
android:pivotY="300.0"
android:rotation="45.0" >
<path
android:fillColor="#000000"
android:pathData="M300,70 l 0,-70 70,70 0,0 -70,70z" />
</group>
</vector>
</aapt:attr>
<target android:name="rotationGroup">
<aapt:attr name="android:animation" >
<objectAnimator
android:duration="6000"
android:propertyName="rotation"
android:valueFrom="0"
android:valueTo="360" />
</aapt:attr>
</target>
</animated-vector>
<aapt:attr >
XML etiketi, AAPT'ye etiketin alt öğesini bir
kaynak dosyasına aktarmanızı öneririz. Özellik adındaki değer,
kullanın.
AAPT tüm satır içi kaynaklar için kaynak dosyaları ve adlar oluşturur.
Bu satır içi biçim kullanılarak oluşturulan uygulamalar tüm Android sürümleriyle uyumludur.
Bu sayfadaki içerik ve kod örnekleri, İçerik Lisansı sayfasında açıklanan lisanslara tabidir. Java ve OpenJDK, Oracle ve/veya satış ortaklarının tescilli ticari markasıdır.
Son güncelleme tarihi: 2025-07-27 UTC.
[null,null,["Son güncelleme tarihi: 2025-07-27 UTC."],[],[],null,["# Inline complex XML resources\n\nCertain resource types are a composition of multiple complex resources represented by XML files.\nOne example is an animated vector drawable, which is a drawable resource encapsulating a vector\ndrawable and an animation. This requires the use of at least three XML files, as shown in the\nfollowing\nexamples.\n\n`res/drawable/avd.xml`\n:\n\n ```xml\n \u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n \u003canimated-vector xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android:drawable=\"@drawable/vectordrawable\" \u003e\n \u003ctarget\n android:name=\"rotationGroup\"\n android:animation=\"@anim/rotation\" /\u003e\n \u003c/animated-vector\u003e\n ```\n\n`res/drawable/vectordrawable.xml`\n:\n\n ```xml\n \u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n \u003cvector xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android:height=\"64dp\"\n android:width=\"64dp\"\n android:viewportHeight=\"600\"\n android:viewportWidth=\"600\" \u003e\n \u003cgroup\n android:name=\"rotationGroup\"\n android:pivotX=\"300.0\"\n android:pivotY=\"300.0\"\n android:rotation=\"45.0\" \u003e\n \u003cpath\n android:fillColor=\"#000000\"\n android:pathData=\"M300,70 l 0,-70 70,70 0,0 -70,70z\" /\u003e\n \u003c/group\u003e\n \u003c/vector\u003e\n ```\n\n`res/anim/rotation.xml`\n:\n\n ```xml\n \u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n \u003cobjectAnimator xmlns:android=\"http://schemas.android.com/apk/android\"\n android:duration=\"6000\"\n android:propertyName=\"rotation\"\n android:valueFrom=\"0\"\n android:valueTo=\"360\" /\u003e\n ```\n\n\nIf the vector drawable and animations are re-used elsewhere, this is the best way to implement an\nanimated vector drawable. But if these files are only used for this animated vector drawable,\nthen there is a more compact way to implement them.\n\nUsing AAPT's inline resource format, you can define all three resources in the same XML file, as\nshown in the following example.\nFor an animated vector drawable, put the file under `res/drawable/`.\n\n`res/drawable/avd.xml`\n:\n\n ```xml\n \u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n \u003canimated-vector xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:aapt=\"http://schemas.android.com/aapt\" \u003e\n\n \u003caapt:attr name=\"android:drawable\" \u003e\n \u003cvector\n android:height=\"64dp\"\n android:width=\"64dp\"\n android:viewportHeight=\"600\"\n android:viewportWidth=\"600\" \u003e\n \u003cgroup\n android:name=\"rotationGroup\"\n android:pivotX=\"300.0\"\n android:pivotY=\"300.0\"\n android:rotation=\"45.0\" \u003e\n \u003cpath\n android:fillColor=\"#000000\"\n android:pathData=\"M300,70 l 0,-70 70,70 0,0 -70,70z\" /\u003e\n \u003c/group\u003e\n \u003c/vector\u003e\n \u003c/aapt:attr\u003e\n\n \u003ctarget android:name=\"rotationGroup\"\u003e\n \u003caapt:attr name=\"android:animation\" \u003e\n \u003cobjectAnimator\n android:duration=\"6000\"\n android:propertyName=\"rotation\"\n android:valueFrom=\"0\"\n android:valueTo=\"360\" /\u003e\n \u003c/aapt:attr\u003e\n \u003c/target\u003e\n \u003c/animated-vector\u003e\n ```\n\nThe XML tag `\u003caapt:attr \u003e` tells AAPT to treat the tag's child as a\nresource and extract it into its own resource file. The value in the attribute name specifies where\nto use the inline resource within the parent tag.\n\nAAPT generates resource files and names for all the inline resources.\nApplications built using this inline format are compatible with all versions of Android."]]