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
あるあるLT 2019/11/27
Search
k-shinn
November 27, 2019
Programming
20
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
あるあるLT 2019/11/27
k-shinn
November 27, 2019
Other Decks in Programming
See All in Programming
カツオ、ご期待ください
suneo3476
0
190
AIで開発が速くなった先で、開発チームは何を目指すか
shihochan
0
1.2k
Simple Storage Service(S3) is not simple
iwatsukayura
0
290
自サークルのIdPからログアウトできるようになるまで
taiseiue
1
140
Apple Intelligence を用いた個人情報誤送信防止、及びユーザーリクエスト体験の改善について
yukiny
0
350
ActionController meets Protocol Buffers
sorah
0
520
AWS CDKのカスタムリソースでContinuum(旧Security Agent)を実装した話 | Implementing Continuum (formerly Security Agent) via AWS CDK Custom Resource
akihisaikeda
2
150
AIに “答え“を書かせるのを やめてみた
___akari11
0
120
Atomic Design, Enforced: Scaling Mobile Design Systems (next.app devCon / droidCon Berlin 2026)
steliosf
PRO
0
170
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
2
1.6k
コードで差別化できない時代の ソフトウェアエンジニアリング / Software Engineering in an Era Where Code Doesn’t Differentiate
kishida
2
180
[ハンズオン]AIへの指示だけで「五目並べ」を作ってみよう
satoshi256kbyte
1
380
Featured
See All Featured
Into the Great Unknown - MozCon
thekraken
41
2.8k
HDC tutorial
michielstock
2
960
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
3.4k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.8k
Raft: Consensus for Rubyists
vanstee
142
7.8k
Utilizing Notion as your number one productivity tool
mfonobong
4
620
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
Building a Scalable Design System with Sketch
lauravandoore
464
34k
It's Worth the Effort
3n
188
29k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.3k
Transcript
ConstraintLayout ͋Δ͋Δ(͡Όͳ͍͔͠Εͳ͍) ͋Δ͋ΔLTʙ AndroidΞϓϦ։ൃΤϯδχΞ ʙ Vol.8 oshima @and factory 1
About Me େౡ / @k_shinnʢఀؾຯʣ and factoryגࣜձࣾ AndroidΤϯδχΞ ೖࣾ1νϣοτɺAndroidྺ4.5͘Β͍ ͍ΞϓϦ୲த
2
ConstraintLayout ͬͯ·͔͢ʁ 3
and factoryͰ࠷ۙࣾษڧձͰʹͯ͠·ͨ͠ 4
ࠓճࣾษڧձͰग़ͨΛத৺ʹ ʮ͋Δ͋Δʯʮ͋Δ͋Δ…ʁʯΛ͝հ 5
ͦͷ̍ɽTextView͕Έग़͕ͪ 6
ྫʣ͜͏͍͏Layout࡞ͬͯͨΒ… • ໊ʴஈͷ߲ • ߲෯ʢ৭͖ͷ෦ʣݻఆ 7
λΠτϧ͕͘ͳͬͨΒࠨӈʹΈग़ͨ • ໊ͷ಄ͱஈͷඌ͕֎ʹΈग़ͨ • • ཧͱͯ͠ʹऩ·ͬͯඌলུ 8
ʢͳΜͰ͔ʣ͓͔Γ͍͚ͨͩͨͩΖ͏͔ʁ 9
ࠨͷtextΛ `wrap_content` ʹͯͨ͠ͷ͕ݪҼ • `wrap_content`Viewͷ͞·Ͱ෯Λͱͬͯ͠·͏ • Φʔόʔ͢ΔͱࠨӈۉʹΈग़Δ 10 <TextView android:id="@+id/text1"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=“λΠτϧλΠτϧʢུ” ………
ͪͳΈʹ… • ChainStyle+biasࢦఆ͢ΔͱͣΕΔํยํʹدΔ 11 <TextView … app:layout_constraintHorizontal_bias="0.0" app:layout_constraintHorizontal_chainStyle=“packed" …
0dp(match_constraint)Λ͓͏ • ੍ݶతʹՄೳͳൣғΛ֬อͯ͘͠ΕΔ • LinearLayoutͰ͍͏weight=1 • 0dpʹͨ͠Օॴ͕༨നΛશ෦͍࣋ͬͯ͘ͱߟ͑Δͱָ 12
13 <TextView android:id="@+id/text1" android:layout_width=“0dp" // Γͷԣ෯·Ͱ͕ॆ͕ͯΘΕΔ android:layout_height="wrap_content" android:layout_margin="4dp" android:ellipsize="end" android:lines="1"
android:text="λΠτϧλΠτϧ" android:textStyle="bold" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toStartOf="@id/text2" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <TextView android:id="@+id/text2" android:layout_width=“wrap_content" // ͪ͜Βͷԣ෯֬อ͞ΕΔ android:layout_height="wrap_content" android:layout_margin="4dp" android:text="500ԁ" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toEndOf="@id/text1" app:layout_constraintTop_toTopOf="parent" />
ͨͩ͠… • 0dp≒༨ന • ଞͷView͕ेʹେ͖͍ͱදࣔ͞Εͳ͘ͳΔ • λΠτϧଘࡏͯ͠Δ͚ͲஈʹӅ͞Εͨਤ 14
wrap_contentͱ0dpͷੑ࣭Λཧղ͢Δͱ໘ന͍ 15
ͦͷ̎ɽ `constraintStart_toXxx` ͷࢦఆϛε͕ͪ͠ 16
Ұ൪؊͚ͩͲҰ൪ΊΜͲ͍͘͞෦ 17 <TextView android:id="@+id/text1" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_margin="4dp" android:ellipsize="end" android:lines="1" android:text="λΠτϧλΠτϧ"
android:textStyle="bold" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toStartOf="@id/text2" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" />
Tips:ิػೳʹཔΔͱͪΐͬͱָʹॻ͚Δ • toptop… ͱ͔ enst… ͱ͔ଧͭ 18
࣮… 19
ඃΒͳ͚Εશ෦ॻ͚Δ • ͜ΕͰBuild௨Γ·͢ 20 <TextView android:id="@+id/text2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="4dp" android:text="500ԁ"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toTopOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toStartOf="parent" app:layout_constraintStart_toEndOf="@id/text1" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="parent" app:layout_constraintTop_toTopOf="parent" />
Ͳ͏ͳΔͷʁ 21
start_to…Λ2ݸ͚ͨ߹ • `start_toStart` ͕༏ઌ͞Εͨ 22 <TextView android:id="@+id/text2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="4dp"
android:text="500ԁ" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toEndOf="@id/text1" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" />
༏ઌॱҐ͕ଘࡏ͢Δ • ConstraintLayoutͷݩιʔεࢀর • ยํ͔͠ఆ͞Εͳ͍ 23 // Left constraint if
(layoutParams.leftToLeft != LayoutParams.UNSET) { // ≒ startToStart ConstraintWidget target = getTargetWidget(layoutParams.leftToLeft); if (target != null) { widget.immediateConnect(ConstraintAnchor.Type.LEFT, target, ConstraintAnchor.Type.LEFT, layoutParams.leftMargin); } } else if (layoutParams.leftToRight != LayoutParams.UNSET) { // ≒ startToEnd ConstraintWidget target = getTargetWidget(layoutParams.leftToRight); if (target != null) { widget.immediateConnect(ConstraintAnchor.Type.LEFT, target, ConstraintAnchor.Type.RIGHT, layoutParams.leftMargin); } }
Build௨Δ…ͱ͍͏͔௨ͬͯ͠·͏᠘ 24
͔͜͜Β౼తͳ༰ 25
ͦͷ̏ɽ xmlϑϧϑϥοτʹ͢ΔͱٯʹݟͮΒ͘ͳ͍ʁ 26
Θ͔Δʢୡ؍ʣ 27
ύϑΥʔϚϯε্͕͕Δͱݴ͏͚ΕͲ… • େମମײ͢Δͷ͕͍͠Ϩϕϧ • ωετ͕͋Δͱߏͷ·ͱ·Γͱͯ͠ݟ͍͢ͷࣄ࣮ 28
ྑ͍ԘകΛ୳Γ͍ͨ • 1.2ஈ֊͘Β͍ͷωετΛڐ༰͢Δͱݟ͘͢ͳΔ • ࠨ٧Ίͷ୯७Layoutͱ͔Linearͱ͍͚Δͱ͍͍͔ 29
ͦͷ̐ɽLinearͰྑ͘ͳ͍ʁ 30
Θ͔Δʢଥڠʣ 31
ศརػೳ͕ͨ͘͞Μ͋ΔͷͰ৭ʑڭ͠Α͏ʂʂ ʢ༰͜Εʹ͢Δ͔͔ͳΓ໎ͬͨʣ 32
ݸਓతڭϙΠϯτ • GUIͰ༨ന֬ೝௐઅͯ͠ΈΔ • ChainStyleΛͬͯ༨നΛ͍͍ײ͡ʹ͢Δ • BarrierͰՄมͳԣ෯Λ؆୯ʹἧ͑ͯΈΔ 33
ConstraintLayoutා͘ͳ͍ʂ 34
ࢀߟ • ConstraintLayout • https://android.googlesource.com/platform/frameworks/opt/ sherpa/+/studio-2.2/constraintlayout/src/main/java/android/ support/constraint/ConstraintLayout.java • 35