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
View into the abyss
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Mori Masaki
February 19, 2016
Technology
400
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
View into the abyss
Mori Masaki
February 19, 2016
Other Decks in Technology
See All in Technology
深夜のクラウド懺悔室 1:29:300 or 1:0:0
kazzpapa3
0
160
JAWS-UG初心者支部#88わいわい初心塾(夏休みの宿題やったかGit編)
otsuki
0
120
DGX Sparkを2台使って いろいろ動かす話
sonoda_mj
1
130
Genie Code ワークショップ 応用編 / Genie-Code-Workshop-advanced
databricksjapan
PRO
0
330
こんなアーキテクチャ図は嫌だ BEYOND THE TIME: 半年後の自分へ贈る15のメッセージ / 15 of Anti-pattern in AWS Architecture Diagrams
naospon
3
230
Azure Cost Management の FOCUS コストデータを迷わず読むための“3つの軸”
tetsuyaooooo
0
140
grill-me(grilling):AI駆動開発を超助けてくれるSkill / grill me
mathbullet
0
100
[DroidKaigi 2026] Making UI specifications visible: Android UI development in the AI agent era supported by Compose Screenshot Testing and galleries
syarihu
0
570
コスト最適化の「めんどくさい」を AWS FinOps Agent でチョット楽にする
classmethod_kaz
0
170
AI-DLCって実際どう? 〜聞きたいこと全部聞いてみる〜
news_it_enj
0
220
振り返りこそエンジニアの本領
negima
0
290
Jetpack Compose で挑む新聞紙面UI ─ 複合ジェスチャー・ポリゴン記事領域・適応的ページ構成という3つの壁/droidkaigi2026
nikkei_engineer_recruiting
0
200
Featured
See All Featured
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.9k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.3k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
500
Build your cross-platform service in a week with App Engine
jlugia
234
19k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
Fireside Chat
paigeccino
42
4k
The Curious Case for Waylosing
cassininazir
1
490
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
410
AI: The stuff that nobody shows you
jnunemaker
PRO
9
970
The Cult of Friendly URLs
andyhume
79
7k
Transcript
VIEW INTO THE ABYSS DROIDKAIGI 2016 MORI Masaki @ SmartNews
None
Supports Android 2.2~ (Froyo)
This talk also works on (almost) every Android
VIEW “A View occupies a rectangular area on the screen
and is responsible for drawing and event handling” http://developer.android.com/intl/ja/ reference/android/view/View.html
All you view is View
VIEW TREE FrameLayout LinearLayout Button ImageView TextView RelativeLayout Button
None
3 steps to showing Views Measure - Layout - Draw
MEASURE Calculate size with requested constraint
LAYOUT Assign each position to child views
DRAW Render visual contents to Canvas
FrameLayout LinearLayout Button ImageView TextView RelativeLayout Button ViewRootImpl when setText(…)
is called
FrameLayout LinearLayout Button ImageView TextView RelativeLayout Button ViewRootImpl requestLayout requestLayout
requestLayout requestLayout View root receives requestLayout() call
FrameLayout LinearLayout Button ImageView TextView RelativeLayout Button ViewRootImpl measure, measure,
measure, measure… measure, measure measure, measure measure measure, measure Determine sizes of all Views
FrameLayout LinearLayout Button ImageView TextView RelativeLayout Button ViewRootImpl layout layout
layout layout layout Determine positions of all Views
HOW TO CUSTOM @Override void onMeasure(int widthMeasureSpec, int heightMeasureSpec) @Override
void onLayout(boolean changed, int l, int t, int r, int b) (for ViewGroup)
onMeasure: call children’s measure() and this.setMeasuredDimension() onLayout: call children’s layout()
Responsive LinearLayout
public class AdFooter extends LinearLayout { @Override protected void onMeasure(int
widthMeasureSpec, int heightMeasureSpec) { switchLayoutHorizontal(); super.onMeasure(widthMeasureSpec, heightMeasureSpec); if (isOverflowed()) { switchLayoutVertical(); super.onMeasure(widthMeasureSpec, heightMeasureSpec); } } } Responsive LinearLayout
PERFORMANCE TIPS Avoid requestLayout() call as much as possible
removeView(oldView); addView(view, index, params); removeViewInLayout(oldView); addViewInLayout(view, index, params, true); if
(!isLayoutRequested()) { view.measure(widthMeasureSpec, heightMeasureSpec); view.layout(left, top, right, bottom); } SLOW FAST Replace child w/o layout
setImageDrawable() causes requestLayout
public class LayoutBlockingImageView extends ImageView { private boolean preventLayout; @Override
public void setImageDrawable(Drawable drawable) { preventLayout = true; super.setImageDrawable(drawable); preventLayout = false; } @Override public void requestLayout() { if (!preventLayout) super.requestLayout(); } } Needless for fixed ImageView
FrameLayout LinearLayout Button ImageView TextView RelativeLayout Button ViewRootImpl setTextColor(…) called
FrameLayout LinearLayout Button ImageView TextView RelativeLayout Button ViewRootImpl invalidate invalidate
invalidate invalidate View root receives invalidate() call
FrameLayout LinearLayout Button ImageView TextView RelativeLayout Button ViewRootImpl draw draw
draw draw draw Render visual contents to Canvas
HOW TO CUSTOM setWillNotDraw(false); @Override void onDraw(Canvas canvas)
None
leftView rightView
@Override protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
canvas.save(Canvas.CLIP_SAVE_FLAG); try { if (child == leftView) { canvas.clipRect(0, 0, splitPositionLeft, height); } else if (child == rightView) { canvas.clipRect(splitPositionRight, 0, width, height); } return super.drawChild(canvas, child, drawingTime); } finally { canvas.restore(); } } Clipping child Views
PERFORMANCE TIPS Skip heavy jobs on animation as much as
possible
Animating Stopped
Animating Stopped Kill shadows and anti-alias
Prefer invalidate(l, t, r, b)
setLayerType(LAYER_TYPE_HARDWARE) only on transition
REMEMBER Profile before Optimizing
BEST REFERENCE https://github.com/android/ platform_frameworks_base