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
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
Digitization部 紹介資料
sansan33
PRO
2
7.7k
20260608_Codexの可能性_ノンプログラマー向け_大城追記
doradora09
PRO
0
780
FORENSIA: ローカルLLMフォレンジックハーネス
sumeshi
2
350
修正PRを食べてレビュースキルが賢くなる:Claude Codeによる自己改善サイクル
yuyaumetsu
5
1.4k
認知負荷をGemini で溶かす — GKE 基盤「Orbit」における AI エージェントの実践
sansantech
PRO
1
270
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
1.2k
Service Connect 上のサービスに ECS Service の外側から到達できなかった話
ota1022
1
150
LLM・AIエージェントシステムベストプラクティス
shibuiwilliam
2
380
Issue設計から始める仕様駆動開発 / 20260731 Mizuki Hirata
shift_evolve
PRO
1
150
つくって納得、つかって実感! 大規模言語モデルことはじめ ver2.0
recruitengineers
PRO
3
1.2k
Breaking the Seal: Static Deobfuscation of Compiled V8 JavaScript Bytecode Malware
hshrzd
0
650
[ChatGPT Work LT]事務作業が苦手な人のための バックオフィスの「半」自動化
chimaki_iot
0
250
Featured
See All Featured
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Facilitating Awesome Meetings
lara
57
7.1k
Documentation Writing (for coders)
carmenintech
77
5.4k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
790
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
64
56k
Why Our Code Smells
bkeepers
PRO
340
58k
Music & Morning Musume
bryan
47
7.3k
Typedesign – Prime Four
hannesfritz
42
3.1k
4 Signs Your Business is Dying
shpigford
187
22k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
56k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
1.2k
Evolving SEO for Evolving Search Engines
ryanjones
0
250
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