উদাহরণের আগে জানতে হবে Vertical Scroll View (ScrollView) কী। এটি android.widget.ScrollView ক্লাস দ্বারা প্রদত্ত। এটি চাইল্ড ভিউগুলো ভার্টিক্যাল ডিরেকশনে স্ক্রোল করতে ব্যবহৃত হয়।
এই উদাহরণটি Vertical Scroll View ব্যবহারের পদ্ধতি দেখায়।
ধাপ ১: নতুন প্রজেক্ট তৈরি করুন
অ্যান্ড্রয়েড স্টুডিওতে File → New Project এ যান এবং প্রজেক্ট তৈরির জন্য প্রয়োজনীয় বিবরণ পূরণ করুন।
ধাপ ২: activity_main.xml-এ লেআউট যোগ করুন
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="https://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:id="@+id/layout"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:background="#c1c1c1"
android:layout_height="300dp"
android:src="@drawable/a"/>
<ImageView
android:layout_width="match_parent"
android:background="#c1c1c1"
android:layout_height="300dp"
android:layout_marginTop="30dp"
android:src="@drawable/b"/>
<ImageView
android:layout_width="match_parent"
android:background="#c1c1c1"
android:layout_height="300dp"
android:layout_marginTop="30dp"
android:src="@drawable/c"/>
<ImageView
android:layout_width="match_parent"
android:background="#c1c1c1"
android:layout_height="300dp"
android:layout_marginTop="30dp"
android:src="@drawable/d"/>
<ImageView
android:layout_width="match_parent"
android:background="#c1c1c1"
android:layout_height="300dp"
android:layout_marginTop="30dp"
android:src="@drawable/e"/>
</LinearLayout>
</ScrollView>
</LinearLayout>
এখানে LinearLayout প্যারেন্ট এবং ScrollView চাইল্ড হিসেবে। ScrollView চাইল্ড ভিউগুলো ভার্টিক্যালি স্ক্রোল করাবে, তাই এর চাইল্ড হিসেবে LinearLayout (ভার্টিক্যাল অরিয়েন্টেশন) নেওয়া হয়েছে এবং ৫টি ইমেজ ভিউ যোগ করা হয়েছে।
ধাপ ৩: Manifest.xml এবং Activity-তে কোনো পরিবর্তন প্রয়োজন নেই
আউটপুট
প্রাথমিক স্ক্রিন:

ভার্টিক্যালি স্ক্রোল করলে:

অন্তিম পজিশনে পৌঁছালে:
