Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
M3 NavigationBar をマスターする
Search
akkiee76
November 05, 2023
Technology
1.1k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
M3 NavigationBar をマスターする
akkiee76
November 05, 2023
More Decks by akkiee76
See All by akkiee76
EmptyViewは本当に“空”なのか?
akkie76
0
84
Graph Art with Charts API – Beyond Data Visualization
akkie76
0
280
Meet the Translation API
akkie76
0
530
コードレビューで開発を加速させるAIコードレビュー
akkie76
1
830
Android Target SDK 35 (Android 15) 対応の概要
akkie76
0
6.2k
コードレビューを支援するAI技術の応用
akkie76
5
1.3k
オブジェクト指向コードレビューの新しいアプローチ
akkie76
3
10k
Jetpack Compose で Adaptive Layout に対応しよう
akkie76
0
1.3k
Observationではじめる値監視
akkie76
4
4.9k
Other Decks in Technology
See All in Technology
全PRの83%が AIレビューだけでマージできるようになった開発組織は その後どうなったか @2026/10
athug
0
130
子育てエンジニアの可処分時間が減っても成長を諦めない戦い方
sudoakiy
5
4.3k
ビジネスを止めない技術的負債の返済のための戦略とその手法 - 技術的負債と向き合う / Complexity and Simplicity
soudai
PRO
3
680
The seven pitfalls of AI (revised version)
ufried
0
310
二歩目のフロントエンド・ウェブアクセシビリティ
camiha
2
250
スキルを作る、その前に!複数人で使われるスキルを 作るためのプロセス
junkifurukawa
2
370
あなたの知らないAmazon VPC Route Server/Amazon VPC Route Server you don't know about
masakiokuda
2
250
継続的なAIコスト最適化
bgpat
1
270
1万名の社員が使う認証基盤で どう信頼性を担保するか?
kairim0
0
220
UniFi(ユニファイ)AIカメラの現場活用
ludicmind
1
390
ブラウザとサーバーから考えるAI時代のフロントエンド監視
shogo4131
3
630
オブザーバビリティを高める AI エージェント体験を考える / Designing AI Agent Experiences That Enhance Observability
aoto
PRO
2
320
Featured
See All Featured
Building Flexible Design Systems
yeseniaperezcruz
330
41k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.5k
The untapped power of vector embeddings
frankvandijk
2
1.9k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
280
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.2k
How to train your dragon (web standard)
notwaldorf
96
6.9k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
540
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
Bash Introduction
62gerente
615
220k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
2
350
Everyday Curiosity
cassininazir
0
350
How to build a perfect <img>
jonoalderson
1
6.1k
Transcript
©2023 RAKUS Co., Ltd. M3 NavigationBar をマスターする Shibuya.apk #45 2023/11/10
@akkiee76
Akihiko Sato 株式会社ラクス / 楽楽精算 / モバイル開発チーム @akkiee76 自己紹介
M3 NavigationBar 概要 • 画面下部に表示し、ナビゲーションを提供するコンポーネント • M2 BottomNavigation が M3
NavigationBar に名称変更 • NavigationBar の要素は NavigationBarItem • 「Bottom Navigation Views Activity」 は M3 Compose 非対応 https://developer.android.com/jetpack/compose/designsystems/material2-material3?hl=ja#bottom-navigation NavigationBar BottomNavigation
Implementation 1. NavigationBar を設定する 2. NavigationBarItem を追加する 3. 画面切り替えを行う 4.
Badge を付ける
Let's Implement 🛠
1. NavigationBar を設定する Scaffold( bottomBar = { NavigationBar { }
} ) { Surface( modifier = Modifier .padding(bottom = it.calculateBottomPadding()) ) { }
2. NavigationBarItem を追加する enum class NavigationItem ( val label: String,
@DrawableRes val resId: Int ) { HOME("Home", R.drawable.ic_home), EXPLORE("Explore", R.drawable.ic_fmd_good), MESSAGE("Message", R.drawable.ic_chat), STARRED("For You", R.drawable.ic_star); }
Scaffold( bottomBar = { NavigationBar { NavigationItem.entries.forEach { item ->
NavigationBarItem( selected = false, onClick = {}, icon = { Icon( painter = painterResource(id = item.resId), contentDescription = null ) }, label = { Text(text = item.label) } ) } } } 2. NavigationBarItem を追加する
NavigationBarItem の注意点(M3 Guidelines) OK Don’t • ユーザにとって遷移が明確であること • NavigationBarItem は
3 ~ 5 であること • Label を表示すること https://m3.material.io/components/navigation-bar/guidelines
build.gradle.kts dependencies { implementation("androidx.navigation:navigation-compose:2.7.4" ) } val navController = rememberNavController
() Scaffold(bottomBar = { // NavigationBar } ) { Surface(modifier = Modifier.padding(bottom = it.calculateBottomPadding())) { NavHost(navController = navController , startDestination = NavigationItem .HOME.route) { composable(NavigationItem .HOME.route) { HomeScreen() } composable(NavigationItem .EXPLORE.route) { ExploreScreen () } composable(NavigationItem .MESSAGE.route) { MessageScreen () } composable(NavigationItem .STARRED.route) { FavoriteScreen () } } 3. Navigation を行う
val navBackStackEntry by navController.currentBackStackEntryAsState() val destination = navBackStackEntry?.destination NavigationBar {
NavigationItem.entries.forEach { item -> val selected = destination?.hierarchy ?.any { it.route == item.route } == true NavigationBarItem( selected = selected, onClick = { navController.navigate(item.route) { launchSingleTop = true } }, icon = { }, label = { } ) } } 3. Navigation を行う https://developer.android.com/jetpack/compose/navigation?hl=ja#bottom-nav
NavigationBarItem( icon = { BadgedBox( badge = { Badge() }
) { Icon( painter = painterResource(id = item.resId), contentDescription = null ) } 4. Badge を付ける
@ExperimentalMaterial3Api @Composable fun Badge( modifier: Modifier = Modifier, containerColor: Color
= BadgeDefaults.containerColor, contentColor: Color = contentColorFor(containerColor), content: @Composable (RowScope.() -> Unit)? = null, ) BadgedBox( badge = { Badge { Text(text = "1") } }) { Icon( painter = painterResource(id = item.resId), contentDescription = null ) } 4. Badge を付ける(カスタマイズ)
Implementation completed 🛠
Material Design 3 Guidelines 👀
Item 設定の注意点 • 選択時のアイコンは filled(塗りつぶし)を使用すること https://m3.material.io/components/navigation-bar/guidelines OK Caution • Label
は明確かつ十分なコントラストを設定すること OK Don’t Don’t
NavigationBarItem( selected = selected, onClick = onClick, icon = {
val resId = if (selected) item.filledResId else item.outlinedResId Icon( painter = painterResource(id = resId), contentDescription = null ) }, label = { val fontWeight = if (selected) FontWeight.Bold else FontWeight.Normal Text( text = item.label, fontWeight = fontWeight ) } ) M3 Guidelines に準拠する
Implementation completed 🎉
まとめ • NavigationBar は Item を content に指定するだけで 実装可能 ◦
NavigationBarItem の Composable に詳細設定 • M3 Guidelines のチェックも忘れずに
Thank you 🎉