Layout Width/Height: match_parent vs wrap_content
এই উদাহরণে fill_parent (पुरনো নাম, এখন match_parent) এবং wrap_content-এর পার্থক্য দৃশ্যমান করা হয়েছে।
প্রথম ধাপ: প্রজেক্ট তৈরি করুন
Android Studio-তে নতুন প্রজেক্ট তৈরি করুন।
দ্বিতীয় ধাপ: লেআউট ফাইল - পার্থক্য দেখানো
res/layout/activity_main.xml - দুটি TextView একসাথে:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context=".MainActivity">
<!-- match_parent (পুরনো fill_parent) - প্যারেন্টের পুরো জায়গা নেবে -->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="A wiki is run using wiki software, otherwise known as a wiki engine. A wiki engine is a type of content management system, but it differs from most other such systems, including blog software, in that the content is created without any defined owner or leader, and wikis have little inherent structure, allowing structure to emerge according to the needs of the users."/>
<!-- wrap_content - কনটেন্টের আকারানুসারি জায়গা নেবে -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="This is a Wrap text"/>
</RelativeLayout>
তৃতীয় ধাপ: মেইন এক্টিভিটি
src/MainActivity.java - শুধু লেআউট লোড করা:
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
চতুর্থ ধাপ: ম্যানিফেস্ট ফাইল
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="https://schemas.android.com/apk/res/android"
package="app.com.sample">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
পার্থক্যের ব্যাখ্যা
match_parent (পুরনো নাম: fill_parent)
- প্যারেন্ট ভিউগ্রুপের **পুরো উপলব্ধ জায়গা** নেয়
- API Level 8 (Android 2.2) থেকে
fill_parent-কেmatch_parent-এ রিনেম করা হয়েছে - উভয়ই কাজ করে কিন্তুmatch_parentপ্রস্তাবিত - উদাহরণে: প্রথম TextView স্ক্রিনের পুরো প্রস্থ এবং উচ্চতা আচ্ছাদন করে
wrap_content
- ভিউটি তার **কনটেন্টের আকারানুসারি** ছোট বা বড় হয়
- শুধু টেক্সট/চাইল্ড ভিউগুলোর জন্য প্রয়োজনীয় জায়গা নেয়
- উদাহরণে: দ্বিতীয় TextView শুধু "This is a Wrap text" লেখাটির আকারে থাকে, স্ক্রিনের মাঝখানে
দৃশ্যমান পার্থক্য
স্ক্রিনশটে দেখতে পাবেন:
- লাল ব্যাকগ্রাউন্ডের TextView (match_parent) - পুরো স্ক্রিন কভার করেছে
- সাদা টেক্সট (wrap_content) - শুধু লেখার পরিমাণ জায়গা নিচ্ছে, স্ক্রিনের মাঝখানে
অ্যাপ্লিকেশন চালান
Run করলে দুটি TextView-এর আকারের পার্থক্য স্পষ্ট দেখাবে।

FillParent/Match parent: Fill parent হল পুরনো নাম, আপডেটেড সংস্করণটি match_parent যা পুরো স্ক্রিন নেয়।
Wrap Content: Wrap content টেক্সটের দৈর্ঘ্য অনুযায়ী আকার নেয় এবং তার কনটেন্ট র্যাপ করে। উদাহরণ: "This is a Wrap Text"। Wrap content "This"-এ থেকে শুরু হয় এবং "text"-এ শেষ হয়।