VectorDrawable ব্যবহার করে অ্যান্ড্রয়েডে হার্ট (Love) আকার বানানো
এই টিউটোরিয়ালে দেখানো হয়েছে কিভাবে একটি ক্লাসিক হৃৎপিণ্ড (Heart) আকার XML ভেক্টর ড্রেয়েবল হিসেবে তৈরি করা যায়। এটি ফেভারাইট, লাইক বাটন, ভ্যালেন্টাইন থিমড অ্যাপে ব্যবহার করা হয়।
ধাপ ১: নতুন প্রজেক্ট তৈরি করুন
Android Studio-তে File → New Project দিয়ে প্রজেক্ট তৈরি করুন।
ধাপ ২: লেয়াউট ফাইল (res/layout/activity_main.xml)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="https://schemas.android.com/apk/res/android"
xmlns:tools="https://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
android:layout_marginTop="30dp"
tools:context=".MainActivity">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@drawable/background" />
</LinearLayout>
ধাপ ৩: ভেক্টর ড্রেয়েবল (drawable/background.xml)
পাথ ডেটা একটি Симেট্রিক্যাল হার্ট আকার তৈরি করে। রঙ লাল (#D80027)। ভিউপোর্ট ৪৯২.৭১৯।
<?xml version="1.0" encoding="utf-8"?>
<vector
xmlns:android="https://schemas.android.com/apk/res/android"
android:autoMirrored="true"
android:height="24dp"
android:viewportHeight="492.719"
android:viewportWidth="492.719"
android:width="24dp">
<path
android:fillColor="#D80027"
android:pathData="M492.719,166.008c0,-73.486 -59.573,-133.056 -133.059,-133.056c-47.985,0 -89.891,25.484 -113.302,63.569c-23.408,-38.085 -65.332,-63.569 -113.316,-63.569C59.556,32.952 0,92.522 0,166.008c0,40.009 17.729,75.803 45.671,100.178l188.545,188.553c3.22,3.22 7.587,5.029 12.142,5.029c4.555,0 8.922,-1.809 12.142,-5.029l188.545,-188.553C474.988,241.811 492.719,206.017 492.719,166.008z"/>
</vector>
অ্যাপ্লিকেশনটি রান করুন
ডিভাইস সংযুক্ত করে Run করুন। একটি লাল হার্ট শেপ দেখাবে।

অ্যানিমেশন যোগ করুন (বোনাস)
হার্ট আইকনে ক্লিক করলে স্কেল অ্যানিমেশন (Pop Effect) দিতে ObjectAnimator বা AnimatedVectorDrawable ব্যবহার করুন।
<!-- res/animator/heart_pop.xml -->
<set xmlns:android="https://schemas.android.com/apk/res/android">
<objectAnimator
android:propertyName="scaleX"
android:duration="150"
android:valueFrom="1.0"
android:valueTo="1.3"
android:repeatCount="1"
android:repeatMode="reverse"/>
<objectAnimator
android:propertyName="scaleY"
android:duration="150"
android:valueFrom="1.0"
android:valueTo="1.3"
android:repeatCount="1"
android:repeatMode="reverse"/>
</set>
// Java-এ
ObjectAnimator animator = (ObjectAnimator) AnimatorInflater.loadAnimator(this, R.animator.heart_pop);
animator.setTarget(imageView);
animator.start();