ইনলাইন জটিল XML সম্পদ
সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
নির্দিষ্ট রিসোর্স টাইপ হল একাধিক জটিল রিসোর্সের সংমিশ্রণ যা XML ফাইল দ্বারা উপস্থাপিত হয়। একটি উদাহরণ হল একটি অ্যানিমেটেড ভেক্টর ড্রয়েবল, যা একটি ভেক্টর ড্রয়েবল এবং একটি অ্যানিমেশনকে এনক্যাপসুলেট করে আঁকার যোগ্য সম্পদ। এটির জন্য কমপক্ষে তিনটি XML ফাইল ব্যবহার করতে হবে, যেমনটি নিম্নলিখিত উদাহরণগুলিতে দেখানো হয়েছে৷
-
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" />
যদি ভেক্টর অঙ্কনযোগ্য এবং অ্যানিমেশনগুলি অন্য কোথাও পুনরায় ব্যবহার করা হয় তবে এটি একটি অ্যানিমেটেড ভেক্টর অঙ্কনযোগ্য বাস্তবায়নের সর্বোত্তম উপায়। কিন্তু যদি এই ফাইলগুলি শুধুমাত্র এই অ্যানিমেটেড ভেক্টর ড্রয়েবলের জন্য ব্যবহার করা হয়, তাহলে সেগুলি বাস্তবায়নের আরও কমপ্যাক্ট উপায় আছে।
AAPT এর ইনলাইন রিসোর্স ফরম্যাট ব্যবহার করে, আপনি একই XML ফাইলে তিনটি রিসোর্স সংজ্ঞায়িত করতে পারেন, যেমনটি নিম্নলিখিত উদাহরণে দেখানো হয়েছে। একটি অ্যানিমেটেড ভেক্টর আঁকার জন্য, ফাইলটিকে res/drawable/
অধীনে রাখুন।
-
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>
XML ট্যাগ <aapt:attr >
AAPT কে ট্যাগের সন্তানকে একটি সম্পদ হিসাবে বিবেচনা করতে এবং এটিকে তার নিজস্ব সম্পদ ফাইলে বের করতে বলে। অ্যাট্রিবিউট নামের মানটি প্যারেন্ট ট্যাগের মধ্যে ইনলাইন রিসোর্সটি কোথায় ব্যবহার করতে হবে তা নির্দিষ্ট করে।
AAPT সমস্ত ইনলাইন সংস্থানগুলির জন্য সংস্থান ফাইল এবং নাম তৈরি করে। এই ইনলাইন বিন্যাস ব্যবহার করে নির্মিত অ্যাপ্লিকেশনগুলি Android এর সমস্ত সংস্করণের সাথে সামঞ্জস্যপূর্ণ।
এই পৃষ্ঠার কন্টেন্ট ও কোডের নমুনাগুলি Content License-এ বর্ণিত লাইসেন্সের অধীনস্থ। Java এবং OpenJDK হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-07-29 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-29 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."]]