একটি ছোট টপ অ্যাপ বার তৈরি করতে, TopAppBar কম্পোজেবল ব্যবহার করুন। এটি সবচেয়ে সহজ সম্ভাব্য শীর্ষ অ্যাপ বার এবং এই উদাহরণে শুধু একটি শিরোনাম রয়েছে।
নিম্নলিখিত উদাহরণটি TopAppBarscrollBehavior জন্য একটি মান পাস করে না, তাই উপরের অ্যাপ বারটি ভিতরের বিষয়বস্তু স্ক্রল করার জন্য প্রতিক্রিয়া দেখায় না।
ফলাফল
চিত্র 1. একটি ছোট শীর্ষ অ্যাপ বার।
কেন্দ্রে সারিবদ্ধ শীর্ষ অ্যাপ বার
কেন্দ্র-সারিবদ্ধ শীর্ষ অ্যাপ বারটি ছোট অ্যাপ বারের মতোই, শিরোনামটি উপাদানটির মধ্যে কেন্দ্রীভূত না হলে। এটি বাস্তবায়ন করতে, ডেডিকেটেড CenterAlignedTopAppBar কম্পোজেবল ব্যবহার করুন।
এই উদাহরণটি enterAlwaysScrollBehavior() ব্যবহার করে scrollBehavior জন্য যে মানটি পাস করে তা পেতে। যখন ব্যবহারকারী স্ক্যাফোল্ডের ভিতরের বিষয়বস্তু স্ক্রোল করে তখন বারটি ভেঙে পড়ে।
ফলাফল
চিত্র 2. একটি কেন্দ্র-সারিবদ্ধ শীর্ষ অ্যাপ বার।
মাঝারি শীর্ষ অ্যাপ বার
মিডিয়াম টপ অ্যাপ বার যেকোন অতিরিক্ত আইকনের নিচে শিরোনাম রাখে। একটি তৈরি করতে, MediumTopAppBar কম্পোজেবল ব্যবহার করুন।
পূর্ববর্তী কোডের মতো, এই উদাহরণটি scrollBehavior জন্য পাস করা মান পেতে enterAlwaysScrollBehavior() ব্যবহার করে।
ফলাফল
চিত্র 3. একটি মাঝারি শীর্ষ অ্যাপ বার যা enterAlwaysScrollBehavior থেকে স্ক্রোল আচরণ প্রদর্শন করে।
বড় টপ অ্যাপ বার
একটি বড় টপ অ্যাপ বার মিডিয়ামের মতোই, যদিও শিরোনাম এবং আইকনগুলির মধ্যে প্যাডিং বেশি এবং এটি সামগ্রিকভাবে স্ক্রিনে আরও বেশি জায়গা দখল করে। একটি তৈরি করতে, LargeTopAppBar ) কম্পোজেবল ব্যবহার করুন।
এই উদাহরণটি exitUntilCollapsedScrollBehavior() ব্যবহার করে এটি scrollBehavior জন্য যে মানটি পাস করে তা পেতে। যখন ব্যবহারকারী স্ক্যাফোল্ডের অভ্যন্তরীণ বিষয়বস্তু স্ক্রোল করে তখন বারটি ভেঙে যায়, কিন্তু তারপর যখন ব্যবহারকারী অভ্যন্তরীণ সামগ্রীর শেষ পর্যন্ত স্ক্রোল করে তখন প্রসারিত হয়।
ফলাফল
চিত্র 4. একটি বড় টপ অ্যাপ বারের উদাহরণ বাস্তবায়ন।
একটি নীচের অ্যাপ বার প্রয়োগ করুন
একটি নিচের অ্যাপ বার তৈরি করতে, BottomAppBar কম্পোজেবল ব্যবহার করুন, যা টপ অ্যাপ বার কম্পোজেবলের মতো।
আপনি নিম্নলিখিত কী প্যারামিটারের জন্য কম্পোজেবল পাস করেন:
actions : আইকনগুলির একটি সিরিজ যা বারের বাম দিকে প্রদর্শিত হয়। এগুলি সাধারণত প্রদত্ত স্ক্রিনের জন্য বা নেভিগেশন আইটেমগুলির জন্য মূল ক্রিয়া।
floatingActionButton : ভাসমান অ্যাকশন বোতামটি বারের ডানদিকে প্রদর্শিত হয়।
ফলাফল
চিত্র 5. নীচের অ্যাপ বারের একটি উদাহরণ বাস্তবায়ন।
মূল পয়েন্ট
আপনি সাধারণত অ্যাপ্লিকেশান বারগুলিকে Scaffold কম্পোজেবলে পাস করেন, যাতে সেগুলি পাওয়ার জন্য নির্দিষ্ট পরামিতি থাকে৷
আপনি শীর্ষ অ্যাপ বারগুলি প্রয়োগ করতে যে কম্পোজেবলগুলি ব্যবহার করেন সেগুলি কী প্যারামিটারগুলি ভাগ করে:
title : অ্যাপ বার জুড়ে প্রদর্শিত পাঠ্য।
navigationIcon : নেভিগেশনের জন্য প্রাথমিক আইকন, যা অ্যাপ বারের বাম দিকে প্রদর্শিত হয়।
actions : আইকন যা ব্যবহারকারীকে কী অ্যাকশনে অ্যাক্সেস দেয়, যা অ্যাপ বারের ডানদিকে দেখা যায়।
scrollBehavior : স্ক্যাফোল্ডের অভ্যন্তরীণ বিষয়বস্তু স্ক্রল করার ক্ষেত্রে শীর্ষ অ্যাপ বারটি কীভাবে সাড়া দেয় তা নির্ধারণ করে।
colors : অ্যাপ বার কিভাবে প্রদর্শিত হবে তা নির্ধারণ করে।
ব্যবহারকারী যখন স্ক্যাফোল্ডের ভিতরের বিষয়বস্তু স্ক্রোল করে তখন অ্যাপ বার কীভাবে প্রতিক্রিয়া জানায় তা আপনি নিয়ন্ত্রণ করতে পারেন। এটি করতে, TopAppBarScrollBehavior এর একটি উদাহরণ তৈরি করুন এবং scrollBehavior প্যারামিটারের জন্য এটি আপনার শীর্ষ অ্যাপ বারে পাস করুন। TopAppBarScrollBehavior তিন ধরনের আছে:
enterAlwaysScrollBehavior : যখন ব্যবহারকারী স্ক্যাফোল্ডের ভেতরের বিষয়বস্তু তুলে ধরেন, তখন উপরের অ্যাপ বারটি ভেঙে পড়ে। ব্যবহারকারী অভ্যন্তরীণ বিষয়বস্তু নিচে টানলে অ্যাপ বার প্রসারিত হয়।
exitUntilCollapsedScrollBehavior : enterAlwaysScrollBehavior এর অনুরূপ, যদিও ব্যবহারকারী যখন স্ক্যাফোল্ডের অভ্যন্তরীণ বিষয়বস্তুর শেষে পৌঁছায় তখন অ্যাপ বারটিও প্রসারিত হয়।
pinnedScrollBehavior : অ্যাপ বারটি যথাস্থানে থাকে এবং স্ক্রল করার ক্ষেত্রে প্রতিক্রিয়া দেখায় না।
এই নির্দেশিকা ধারণকারী সংগ্রহ
এই নির্দেশিকাটি এই কিউরেট করা কুইক গাইড সংগ্রহের অংশ যা বৃহত্তর অ্যান্ড্রয়েড উন্নয়ন লক্ষ্যগুলি কভার করে:
ইন্টারেক্টিভ উপাদান প্রদর্শন
মেটেরিয়াল ডিজাইন ডিজাইন সিস্টেমের উপর ভিত্তি করে কীভাবে কম্পোজেবল ফাংশনগুলি আপনাকে সহজেই সুন্দর UI উপাদান তৈরি করতে সক্ষম করে তা শিখুন।
এই পৃষ্ঠার কন্টেন্ট ও কোডের নমুনাগুলি Content License-এ বর্ণিত লাইসেন্সের অধীনস্থ। Java এবং OpenJDK হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-02-06 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-02-06 UTC-তে শেষবার আপডেট করা হয়েছে।"],[],[],null,["\u003cbr /\u003e\n\nApp bars are containers at the top or the bottom of the screen that give your\nusers access to key features and navigation items:\n\n| Type | Appearance | Purpose |\n|---------------------------|----------------------------------|-------------------------------------------------------------------------------------------------------------------------------|\n| [Top app bar](#top) | Across the top of the screen. | Provides access to key tasks and information. Typically hosts a title, core action items, and certain navigation items. |\n| [Bottom app bar](#bottom) | Across the bottom of the screen. | Typically includes core navigation items. Might give access to other actions, for example, by using a floating action button. |\n\nVersion compatibility\n\nThis implementation requires that your project minSDK be set to API level 21 or\nhigher.\n\nDependencies\n\nImplement a top app bar\n\nThe following code shows implementations for the four types of top app bars,\nincluding varying examples of how you can control scroll behavior.\n\n- [Small top app bar](#small)\n- [Center-aligned top app bar](#center)\n- [Medium top app bar](#medium)\n- [Large top app bar](#large)\n\nSmall top app bar\n\nTo create a small top app bar, use the [`TopAppBar`](/reference/kotlin/androidx/compose/material3/package-summary#TopAppBar(kotlin.Function0,androidx.compose.ui.Modifier,kotlin.Function0,kotlin.Function1,androidx.compose.foundation.layout.WindowInsets,androidx.compose.material3.TopAppBarColors,androidx.compose.material3.TopAppBarScrollBehavior)) composable. This is the\nsimplest possible top app bar and in this example just contains a title.\n\nThe following example does not pass `TopAppBar` a value for\n`scrollBehavior`, so the top app bar does not react to scrolling of the inner\ncontent.\n\nResult **Figure 1.** A small top app bar.\n\nCenter-aligned top app bar\n\nThe center-aligned top app bar is the same as the small app bar,\nexcept the title is centered within the component. To implement it, use the\ndedicated [`CenterAlignedTopAppBar`](/reference/kotlin/androidx/compose/material/package-summary#Scaffold(androidx.compose.foundation.layout.WindowInsets,androidx.compose.ui.Modifier,androidx.compose.material.ScaffoldState,kotlin.Function0,kotlin.Function0,kotlin.Function1,kotlin.Function0,androidx.compose.material.FabPosition,kotlin.Boolean,kotlin.Function1,kotlin.Boolean,androidx.compose.ui.graphics.Shape,androidx.compose.ui.unit.Dp,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,kotlin.Function1)) composable.\n\nThis example uses `enterAlwaysScrollBehavior()` to get the value that it passes\nfor `scrollBehavior`. The bar collapses when the user scrolls the\nscaffold's inner content.\n\nResult **Figure 2.** A center-aligned top app bar.\n\nMedium top app bar\n\nThe medium top app bar places the title beneath any additional icons. To create\none, use the [`MediumTopAppBar`](/reference/kotlin/androidx/compose/material3/package-summary#MediumTopAppBar(kotlin.Function0,androidx.compose.ui.Modifier,kotlin.Function0,kotlin.Function1,androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp,androidx.compose.foundation.layout.WindowInsets,androidx.compose.material3.TopAppBarColors,androidx.compose.material3.TopAppBarScrollBehavior)) composable.\n\nLike the previous code, this example uses `enterAlwaysScrollBehavior()` to\nget the value that it passes for `scrollBehavior`.\n\nResult\n\n\u003cbr /\u003e\n\n**Figure 3.** A medium top app bar demonstrating the scroll behavior from `enterAlwaysScrollBehavior`.\n\n\u003cbr /\u003e\n\nLarge top app bar\n\nA large top app bar is similar to the medium, though the padding between the\ntitle and the icons is greater and it occupies more space on screen overall. To\ncreate one, use the [`LargeTopAppBar`](/reference/kotlin/androidx/compose/material3/package-summary#LargeTopAppBar(kotlin.Function0,androidx.compose.ui.Modifier,kotlin.Function0,kotlin.Function1,androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp,androidx.compose.foundation.layout.WindowInsets,androidx.compose.material3.TopAppBarColors,androidx.compose.material3.TopAppBarScrollBehavior) ) composable.\n\nThis example uses\n`exitUntilCollapsedScrollBehavior()` to get the value that it passes for\n`scrollBehavior`. The bar collapses when the user scrolls the\nscaffold's inner content, but then expands when the user scrolls to the end of\nthe inner content.\n\nResult **Figure 4.** An example implementation of a large top app bar.\n\nImplement a bottom app bar\n\nTo create a bottom app bar, use the [`BottomAppBar`](/reference/kotlin/androidx/compose/material3/package-summary#BottomAppBar(androidx.compose.ui.Modifier,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.ui.unit.Dp,androidx.compose.foundation.layout.PaddingValues,androidx.compose.foundation.layout.WindowInsets,kotlin.Function1)) composable, which is\nsimilar to the top app bar composable.\n\nYou pass composables for the following key\nparameters:\n\n- `actions`: A series of icons that appear on the left side of the bar. These are commonly either key actions for the given screen, or navigation items.\n- `floatingActionButton`: The floating action button that appears on the right side of the bar.\n\n| **Note:** You can also use `BottomAppBar` without passing a value for `actions` and `floatingActionButton`. You create a custom bottom app bar by filling `BottomAppBar` with content as you would other containers.\n\nResult **Figure 5.** An example implementation of a bottom app bar.\n\nKey points\n\n- You generally pass app bars to the `Scaffold` composable, which has specific parameters to receive them.\n- The composables that you use to implement top app\n bars share key parameters:\n\n - `title`: The text that appears across the app bar.\n - `navigationIcon`: The primary icon for navigation, which appears on the left of the app bar.\n - `actions`: Icons that provide the user access to key actions, which appear on the right of the app bar.\n - `scrollBehavior`: Determines how the top app bar responds to scrolling of the scaffold's inner content.\n - `colors`: Determines how the app bar appears.\n- You can control how the app bar responds when the user scrolls the\n scaffold's inner content. To do so, create an instance of\n [`TopAppBarScrollBehavior`](/reference/kotlin/androidx/compose/material3/TopAppBarScrollBehavior) and pass it to your top app bar for the\n `scrollBehavior` parameter. There are three types of `TopAppBarScrollBehavior`:\n\n - `enterAlwaysScrollBehavior`: When the user pulls up the scaffold's inner content, the top app bar collapses. The app bar expands when the user pulls down the inner content.\n - `exitUntilCollapsedScrollBehavior`: Similar to `enterAlwaysScrollBehavior`, though the app bar also expands when the user reaches the end of the scaffold's inner content.\n - `pinnedScrollBehavior`: The app bar remains in place and does not react to scrolling.\n\nCollections that contain this guide\n\nThis guide is part of these curated Quick Guide collections that cover\nbroader Android development goals: \n\nDisplay interactive components \nLearn how composable functions can enable you to easily create beautiful UI components based on the Material Design design system. \n[Quick guide collection](/develop/ui/compose/quick-guides/collections/display-interactive-components) \n\nHave questions or feedback \nGo to our frequently asked questions page and learn about quick guides or reach out and let us know your thoughts. \n[Go to FAQ](/quick-guides/faq) [Leave feedback](https://issuetracker.google.com/issues/new?component=1573691&template=1993320)"]]