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
Mori Masaki
February 19, 2016
Technology
390
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
週末にループ・エンジニアリングの理解を深めるためのスライド
nagatsu
0
170
AWS Security Hub CSPMの成功・失敗体験
cmusudakeisuke
0
540
LayerX コーポレートエンジニアリング室におけるサプライチェーンセキュリティへの取り組み / Supply Chain Security at LayerX Corporate Engineering
yuyatakeyama
3
840
時期が悪い!それでもRaspberry Piを買って遊んで活用するには / 20260627-osc26do-rpi-jikigawarui
akkiesoft
0
800
AI Agentをシステムに組み込む前にゆるく向き合ってみる
hayama17
0
130
不要なレビューをAIにまかせて AIコーディングの環境改善を加速した
shoota
1
260
Oracle Cloud Infrastructure:2026年6月度サービス・アップデート
oracle4engineer
PRO
0
300
ロボティクスの技術 / Robotics Technology
ks91
PRO
0
130
コミュニティの有益性 ~JAWS Days 2026 での体験を通して~ / The Benefits of a Community ~Through My Experience at JAWS Days 2026~
seike460
PRO
0
270
Flow 不死:AI 時代 DevOps 的不變本質
cheng_wei_chen
2
500
いまさら聞けない「仕様駆動開発入門」 〜AI活用時代の開発プロセスを考える〜
findy_eventslides
2
200
「ビジネスがわかるエンジニア」とは何か?
ryooob
0
300
Featured
See All Featured
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
610
Speed Design
sergeychernyshev
33
1.9k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
950
Abbi's Birthday
coloredviolet
3
8.2k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.4k
How to train your dragon (web standard)
notwaldorf
97
6.7k
The Limits of Empathy - UXLibs8
cassininazir
1
370
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.5k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
740
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
The World Runs on Bad Software
bkeepers
PRO
72
12k
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