Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
複雑なレイアウト組む時あるあるは コンポーネント化で解決しよう
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
ぎーにょ
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
270
Google IO 2022 Jetpack Composeのパフォーマンス 社内LT会資料
ginyolith
0
1.4k
各OS1人ずつ開発の辛みあるあるは アーキテクチャで解決出来そう
ginyolith
2
450
クリぼっちでも出来る issue駆動開発
ginyolith
0
600
Other Decks in Technology
See All in Technology
Redmine 7.0で私が開発した新機能の狙いと背景
vividtone
1
110
Tab5をRubyで動くパソコンにする
kishima
1
180
【試作】IoT x AIエージェント
happysamurai294
0
120
AIエージェントの開発・提供におけるセキュリティリスクの論点と対策
flatt_security
1
560
#jawssonic2026 あの時代が悪かった ~動かなかったSageMakerと共に迎えたイベント当日~
ktkn1129
0
130
KAEN Company Deck
kaen
PRO
0
310
AndroidでHDRメディアを「壊さずに」扱う
chigichan24
0
390
IoTハンズオンの舞台裏
shirouz
2
120
データエンジニアリングワークショップ:Auto LoaderとSparkで学ぶデータパイプライン構築
databricksjapan
PRO
0
150
コスト最適化の「めんどくさい」を AWS FinOps Agent でチョット楽にする
classmethod_kaz
0
150
推論の観測、できていますか? 〜 Google Cloud Gemini Enterprise Agent Platformで 3つの Gemini モデルを実測して踏んだ、評価の罠 〜
shukob
PRO
0
140
Genie Code ワークショップ 基礎編 / Genie-Code-Workshop-fundamental
databricksjapan
PRO
0
350
Featured
See All Featured
Bash Introduction
62gerente
615
220k
A better future with KSS
kneath
240
18k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
Designing for Timeless Needs
cassininazir
1
470
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
410
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
A Tale of Four Properties
chriscoyier
163
24k
Context Engineering - Making Every Token Count
addyosmani
9
1.1k
Discover your Explorer Soul
emna__ayadi
2
1.3k
Abbi's Birthday
coloredviolet
3
9.7k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.3k
Crafting Experiences
bethany
1
280
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!!