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
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
書籍セキュアAPIについて
riiimparm
0
250
仕様駆動開発、導入半年。「本当に速くなってるの?」にデータで答える / AICon2026_hirakawa
rakus_dev
0
320
AIツールを導入しても生産性はあがらない? カオナビが直面した 3つの壁と乗り越え方。/ Overcoming 3 Barriers to AI-Driven Productivity at kaonavi
kaonavi
0
180
AICoEでAIネイティブ組織への進化
yukiogawa
0
220
AIコード生成×サプライチェーン攻撃 — PHPが直面する“二重の信頼問題
shinyasaita
0
460
ダッシュボード"開発"について 〜使われるダッシュボードのつくりかた〜
kimichan
0
200
事業成長とAI活用を止めないデータ基盤アーキテクチャの設計思想
hiracky16
0
530
StepFunctionsとGraphRAGを活用した暗黙知活用のためのRAG基盤
yakumo
0
140
Oracle Exadata Database Service on Cloud@Customer X11M (ExaDB-C@C) サービス概要
oracle4engineer
PRO
2
8.5k
探索・可視化・自動化を一本化 Amazon Quickでデータ活用スピードを上げる方法
koheiyoshikawa
0
170
Jitera Company Deck
jitera
0
280
_NIKKEI_Tech_Talk__勉強会は熱量では続かない___17回続いた輪読会の設計術.pdf
_awache
1
100
Featured
See All Featured
Statistics for Hackers
jakevdp
799
230k
Why Our Code Smells
bkeepers
PRO
340
58k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
620
Prompt Engineering for Job Search
mfonobong
0
380
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
190
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
910
Designing for Performance
lara
611
70k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.4k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.5k
Design in an AI World
tapps
1
270
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