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
複雑なレイアウト組む時あるあるは コンポーネント化で解決しよう
Search
ぎーにょ
March 19, 2019
Technology
1.4k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
複雑なレイアウト組む時あるあるは コンポーネント化で解決しよう
ぎーにょ
March 19, 2019
More Decks by ぎーにょ
See All by ぎーにょ
AndroidにおけるNotificationのおさらい & Android16の新API Progress-centric Notifications
ginyolith
0
290
Google IO 2022 Jetpack Composeのパフォーマンス 社内LT会資料
ginyolith
0
1.4k
各OS1人ずつ開発の辛みあるあるは アーキテクチャで解決出来そう
ginyolith
2
450
クリぼっちでも出来る issue駆動開発
ginyolith
0
610
Other Decks in Technology
See All in Technology
ブラウザとサーバーから考えるAI時代のフロントエンド監視
shogo4131
3
1k
Conditional PED-ANOVA: Hyperparameter Importance in Hierarchical & Dynamic Search Spaces
pfn
PRO
0
140
Kiro Crewで「みのるん式」仕事術やってみた
minorun365
PRO
2
570
JAWSUG TOHOKU 青森支部 「LoGoチャット」のAWS移行で 乗り越えたこと
taketakekaho
0
340
触りたくないデータに、どう触るか AI時代のRBACアクセスガバナンス
ivry_presentationmaterials
0
280
⾮構造化データを価値に変える AI エージェント基盤とその組織
ivry_presentationmaterials
0
200
しろおびから始める!ログ活用の第一歩
shumei_ito
0
960
AI × アーキテクト 第1・2章|生成AIの課題とアーキテクトの素養
daidaidai
0
180
1つのリクエストを追って理解する - llm-dのP/D分離
akhino
1
160
Claude の新機能を、 出た日に触って社内に届けるまで
rfdnxbro
1
190
10年後、Engineering 行為を剥奪されるとして、わたしたちは、どう、何を創ればいいだろうか。 / If Engineering Is Taken Away in 10 Years, How and What Should We Create?
bitkey
PRO
1
200
QA4AI 2026-Oct 生成AI時代の品質保証
tokuty
1
890
Featured
See All Featured
Fantastic passwords and where to find them - at NoRuKo
philnash
53
4k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
The Language of Interfaces
destraynor
162
27k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
1
630
Everyday Curiosity
cassininazir
0
360
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
320
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
570
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1k
Designing for Timeless Needs
cassininazir
1
530
Unsuck your backbone
ammeep
672
58k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
Transcript
ෳࡶͳϨΠΞτΉ࣌͋Δ͋Δ ίϯϙʔωϯτԽͰղܾ͠Α͏ ͋Δ͋ΔLTʙεϚϗΞϓϦ։ൃΤϯδχΞʙ VOL.3 2019/03/19 @GINYOLITH_TECH
ςΩετ SELF INTRODUCTION data class Ginyolith( val realName : String
= “Fumiya Akagi", val nickName : String = "ぎーにょ", var belongingTo : String = "株式会社アイリッジ", var position : String = "Androidアプリ開発", val loves : List<String> = mutableListOf( "写真", "アカペラ(音楽)", "インドカレー", "仮面ライダー"), val twitterId : String = "@ginyolith_tech" ) : Human()
AGENDA ࠓ͓͢Δࣄ ▸ ෳࡶͳϨΠΞτΛΉ࣌͋Δ͋Δ ▸ Style/CustomView/include/Fragment ͷಛੑ ▸ Style/CustomView/include/Fragment ͷ͍͚
▸ ݱࡏͷ՝
ARUARU ෳࡶͳϨΠΞτΛΉ࣌͋Δ͋Δ ▸ ωετ͗ͯ͢͠ҙຯෆ໌ʹͳΔlayout.xml ▸ େྔͷViewΛίϯτϩʔϧ͢ΔɺActivity/Fragment/ViewModel ▸ widthheightɺbackgroundͷઃఆʹσδϟϰΛײ͡Δࣄ͕ଟൃ ▸ Α͘Θ͔Μͳ͍͚Ͳdatabinding͕ಈ͔ͳ͍ʢٽʣ
HOW TO COMMONIZE VIEWS VIEWͷڞ௨Խͷํ๏ FRAGMENT INCLUDE STYLE CUSTOM VIEW
ACTIVITY DIMEN.XML
HOW TO COMMONIZE VIEWS ࠓ͓͢Δࣄ FRAGMENT INCLUDE STYLE CUSTOM VIEW
ͦΕͧΕԿ͕ग़དྷΔͷʁ Ͳ͏͍͚Δͷʁ
HOW TO COMMONIZE VIEWS STYLE ▸ ʮView Οϯυͷ֎؍ॻࣜΛࢦఆ͢ΔϓϩύςΟͷू߹ʯ by Google
Developers ▸ ThemeʹԠͯ͡ಈతʹ৭Λఆٛ͢Δ͜ͱՄೳ ▸ ϩδοΫঢ়ଶΛ࣋ͭ͜ͱෆՄೳɻ͋͘·ͰݟͨͷΈ੍ޚ
HOW TO COMMONIZE VIEWS - STYLE - View Οϯυͷ֎؍ॻࣜΛࢦఆ͢ΔϓϩύςΟͷू߹ <View
android:layout_height=“match_parent" android:layout_width="1dp" android:layout_marginBottom=“10dp" android:layout_marginTop=“10dp” android:background=“@color/borderGray”/> <View style="@styleAppTheme.Border.Gray"/>
HOW TO COMMONIZE VIEWS - STYLE - View Οϯυͷ֎؍ॻࣜΛࢦఆ͢ΔϓϩύςΟͷू߹ <View
android:layout_height=“match_parent" android:layout_width="1dp" android:layout_marginBottom=“10dp" android:layout_marginTop=“10dp” android:background=“@color/borderGray”/> <View style="@style/ AppTheme.Border.Gray"/> <style name="AppTheme.Border"> <item name="android:layout_width">match_parent</item> <item name="android:layout_height">1dp</item> <item name="android:layout_marginBottom">10dp</item> <item name="android:layout_marginTop">10dp</item> </style> <style name="AppTheme.Border.Gray" parent="AppTheme.Border"> <item name="android:background">@color/borderGray</item> </style>
HOW TO COMMONIZE VIEWS INCLUDE ▸ layout.xmlͰ࡞ͨ͠ϨΠΞτΛ͍·Θ͢ ▸ ϩδοΫΛแ͠ͳ͍ ▸
ϩδοΫͱϨΠΞτΛͯ͠ɺϩδοΫ͚ͩڞ༗Խ͕Մೳ ▸ ϩδοΫͰContextΛऔಘ͢Δͷ͕͍͠
HOW TO COMMONIZE VIEWS - INCLUDE - ϩδοΫΛแ͠ͳ͍ class UserViewModel()
{ val searchTerm :String fun search() { repository .search(searchTerm) } } <?xml version="1.0" encoding="utf-8"?> <layout> <data> <variable name="viewModel" type=“hoge.UserViewModel”/> </data> <android.support.constraint.ConstraintLayout> <Button android:onClick="@{() -> viewModel.search()}"/> </android.support.constraint.ConstraintLayout> </layout> component_user_search.xml <include layout=“@layout/component_user_search” app:viewModel="@{userViewModel}"/> ϩδοΫͱঢ়ଶΛ ࣋ͭΠϯελϯεΛೖՄ ೳ
<?xml version="1.0" encoding="utf-8"?> <layout> <data> <variable name="viewModel" type=“hoge.UserViewModel”/> </data> <android.support.constraint.ConstraintLayout>
<Button android:onClick="@{() -> viewModel.search()}"/> </android.support.constraint.ConstraintLayout> </layout> HOW TO COMMONIZE VIEWS - INCLUDE - ϩδοΫͱϨΠΞτΛͯ͠ɺϩδοΫ͚ͩڞ༗Խ͕Մೳ component_user_search.xml <?xml version="1.0" encoding="utf-8"?> <layout> <data> <variable name="viewModel" type=“hoge.UserViewModel”/> </data> <android.support.constraint.ConstraintLayout> <TextView android:onClick="@{() -> viewModel.search()}"/> </android.support.constraint.ConstraintLayout> </layout> component_user_search_text.xml ΄΅ߏಉ͕ͩ͡ɺඍົʹݟ ͕ͨҟͳΔ ΄΅ߏಉ͕ͩ͡ɺ ඍົʹݟ͕ͨҟͳΔ
HOW TO COMMONIZE VIEWS - INCLUDE - ϩδοΫͱϨΠΞτΛͯ͠ɺϩδοΫ͚ͩڞ༗Խ͕Մೳ component_user_search.xml <include
layout="@layout/hoge" app:viewModel="@{userViewModel}"/> <include layout=“@layout/fuga" app:viewModel="@{userViewModel}"/> ΄΅ߏಉ͕ͩ͡ɺඍົʹݟ ͕ͨҟͳΔ ϩδοΫͷڞ௨ԽΛɺ ಛघͳॲཧΛॻ͔ͣʹߦ͏͜ͱ͕Մೳ component_user_search_text.xml
HOW TO COMMONIZE VIEWS CUSTOM VIEW ▸ ঢ়ଶͱϩδοΫΛแ ▸ contextΛ༻͍ͨϩδοΫΛ࣮ՄೳʢIntentͷൃߦͳͲʣ
▸ ಠࣗͷattributeΛఆٛग़དྷΔ ▸ طଘͷViewΛ֦ுͯ͠͏͜ͱՄೳ ▸ ViewGroupΛࣗ࡞͢ΔࣄՄೳ ੍͕গͳ͘ɺ෯͍ػೳͱҙຯΛͨͤΒΕΔ
HOW TO COMMONIZE VIEWS - CUSTOM VIEW - ঢ়ଶͱϩδοΫΛแ STYLE
VIEW INCLUDE VIEW VIEW VIEW LOGIC(INJECTED) CUSTOM VIEW VIEW VIEW VIEW LOGIC ATTRIBUTE LOGIC(INJECTED) UI
HOW TO COMMONIZE VIEWS - CUSTOM VIEW - ঢ়ଶͱϩδοΫΛแ CUSTOM
VIEW VIEW VIEW VIEW LOGIC ATTRIBUTE LOGIC(INJECTED) UI ViewͷΈ߹Θͤʢ୯ମViewՄʣ ViewͷݟͨɺଐੑɺStyle Viewݻ༗ͷଐੑΛఆٛՄೳ Viewʹݻ༗ϩδοΫΛΧϓηϧԽ OnClickListenerɺϩδοΫΛೖ
HOW TO COMMONIZE VIEWS FRAGMENT ▸ ಠࣗʹϥΠϑαΠΫϧΛ࣋ͭɻʢ།ҰϥΠϑαΠΫϧपΓͷॲཧΛΧϓηϧԽՄೳʣ ▸ Viewͱͷίϛϡχέʔγϣϯ͍͠ɻ ▸
ಛఆͷActivity/Fragement͔ΒͷΈݺͼग़ͤΔΑ͏ʹ͢Δରࡦ͕ඞཁ ▸ ϩδοΫΛೖग़དྷͳ͍ ▸ CustomViewStyleͱൺɺݟͨΛ͔Β੍ޚ͠ਏ͍ ಠཱੑ͕ߴ͍CUSTOMVIEW
Ͳ͏͍͚Ε͍͍ʁ ಛੑཧղͨ͠
COMPARISON OF COMMONIZING WAYS ൺֱ / Style include CustomView Fragment
LifecycleΛݕ × × ˚ ◦ View͔Βঢ়ଶΛ੍ޚ × ˚ ◦ × layout.xmlͰݟͨΛ੍ޚ ◦ × ◦ × ϩδοΫΛแ × × ◦ ◦ ϩδοΫΛೖ × ◦ ◦ × attr.xmlʹΑΔΧελϜཁૉ × × ◦ ×
COMPARISON OF COMMONIZING WAYS ൺֱ / Style include CustomView Fragment
LifecycleΛݕ × × ˚ ◦ View͔Βঢ়ଶΛ੍ޚ × ˚ ◦ × layout.xmlͰݟͨΛ੍ޚ ◦ × ◦ × ϩδοΫΛแ × × ◦ ◦ ϩδοΫΛೖ × ◦ ◦ × attr.xmlʹΑΔΧελϜཁૉ × × ◦ × ݟͨͷڞ௨ԽʹಛԽ
COMPARISON OF COMMONIZING WAYS ൺֱ / Style include CustomView Fragment
LifecycleΛݕ × × ˚ ◦ View͔Βঢ়ଶΛ੍ޚ × ˚ ◦ × layout.xmlͰݟͨΛ੍ޚ ◦ × ◦ × ϩδοΫΛแ × × ◦ ◦ ϩδοΫΛೖ × ◦ ◦ × attr.xmlʹΑΔΧελϜཁૉ × × ◦ × ϩδοΫΛೖՄೳ
COMPARISON OF COMMONIZING WAYS ൺֱ / Style include CustomView Fragment
LifecycleΛݕ × × ˚ ◦ View͔Βঢ়ଶΛ੍ޚ × ˚ ◦ × layout.xmlͰݟͨΛ੍ޚ ◦ × ◦ × ϩδοΫΛแ × × ◦ ◦ ϩδοΫΛೖ × ◦ ◦ × attr.xmlʹΑΔΧελϜཁૉ × × ◦ × Ұ௨Γग़དྷΔ
COMPARISON OF COMMONIZING WAYS ൺֱ / Style include CustomView Fragment
LifecycleΛݕ × × ˚ ◦ View͔Βঢ়ଶΛ੍ޚ × ˚ ◦ × layout.xmlͰݟͨΛ੍ޚ ◦ × ◦ × ϩδοΫΛแ × × ◦ ◦ ϩδοΫΛೖ × ◦ ◦ × attr.xmlʹΑΔΧελϜཁૉ × × ◦ × VIEW͔Βͷ੍ޚ ʹ੍͓͍ͯ
·ͱΊ
SUMMURY ڞ௨Խର͕ɾɾɾ ෳͷVIEWͷ Έ߹Θͤ STYLE NO Yes ϩδοΫΛ แ Yes
VIEW͔Βݟ ͨΛ੍ޚ INCLUDE NO NO FRAGMENT CUSTOM VIEW Yes
SUMMARY ·ͱΊ ▸ AndroidͷViewͷڞ௨Խʹ৭ʑͳํ๏͕͋Δ ▸ ੍ҙຯ͚ʹԠ͍͚ͯ͡Δͱ… ▸ Ϧʔμϒϧͳίϯϙʔωϯτʹ ▸ ༨ͳ࣮ΛͤͣΑΓޮతʹViewΛ࡞Մೳ
PROBLEMS ՝ ▸ component_ͩͬͨΓview_ͩͬͨΓɺ໋໊نଇ ͕όϥόϥ ▸ atomic designͷߟ͑ํΛద༻ͯ͠componentͷ ཻΛཧग़དྷͳ͍͔ߟ͍͑ͯΔ
THANK YOU FOR LISTENING!!