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
unraveling custom drawing
Search
Matheus Cassiano Candido
August 07, 2018
Programming
0
83
unraveling custom drawing
Matheus Cassiano Candido
August 07, 2018
Tweet
Share
More Decks by Matheus Cassiano Candido
See All by Matheus Cassiano Candido
Kotlin Static Analysis - Kotlin Everywhere 2019
mcassiano
0
88
JUnit rules and test parameterization
mcassiano
0
120
The Basis of Android Threading: Loopers and Handlers
mcassiano
1
120
Hackeando sua próxima entrevista: dicas para conseguir seu próximo estágio ou emprego
mcassiano
1
92
text spans: what, why and how?
mcassiano
0
600
Navigation patterns on Android and something new
mcassiano
3
390
Como conseguir o estágio (ou emprego) dos sonhos
mcassiano
0
45
Databinding e padrão MVVM
mcassiano
1
23
Desenvolvimento móvel: práticas de sucesso
mcassiano
0
26
Other Decks in Programming
See All in Programming
『改訂新版 良いコード/悪いコードで学ぶ設計入門』活用方法−爆速でスキルアップする!効果的な学習アプローチ / effective-learning-of-good-code
minodriven
28
4.3k
非ブラウザランタイムとWeb標準 / Non-Browser Runtimes and Web Standards
petamoriken
0
430
カスタムエフェクトプラグインで Atom Craft をいい感じにする@ADX / ADX LE勉強会 vol.1
cox2
0
110
責務を分離するための例外設計 - PHPカンファレンス 2024
kajitack
9
2.4k
DevinとCursorから学ぶAIエージェントメモリーの設計とMoatの考え方
itarutomy
0
160
return文におけるstd::moveについて
onihusube
1
1.4k
ISUCON14感想戦で85万点まで頑張ってみた
ponyo877
1
610
サーバーゆる勉強会 DBMS の仕組み編
kj455
1
310
どうして手を動かすよりもチーム内のコードレビューを優先するべきなのか
okashoi
3
890
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
6
1.4k
いりゃあせ、PHPカンファレンス名古屋2025 / Welcome to PHP Conference Nagoya 2025
ttskch
1
190
Внедряем бюджетирование, или Как сделать хорошо?
lamodatech
0
950
Featured
See All Featured
Adopting Sorbet at Scale
ufuk
74
9.2k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.3k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
98
18k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
GraphQLとの向き合い方2022年版
quramy
44
13k
Become a Pro
speakerdeck
PRO
26
5.1k
A better future with KSS
kneath
238
17k
Raft: Consensus for Rubyists
vanstee
137
6.7k
What's in a price? How to price your products and services
michaelherold
244
12k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.4k
For a Future-Friendly Web
brad_frost
176
9.5k
Transcript
Desvendando Custom Drawing Matheus C. Candido Android @ Concrete speakerdeck.com/mcassiano
pixabay/somraya
val default = Paint() val smoother = Paint(FLAG_ANTI_ALIAS) val copy
= Paint(smoother)
FLAG_ANTI_ALIAS
stroke width paint.strokeWidth = 4f paint.strokeWidth = 6f paint.strokeWidth =
8f todos os valores são em pixels!
style Paint.Style.STROKE Paint.Style.FILL_AND_STROKE Paint.Style.FILL
join (ligações) Paint.Join.MITER Paint.Join.ROUND Paint.Join.BEVEL
cap (pontas) Source: Microsoft Xamarin Docs
pixabay/coyot
formas
formas canvas.drawRect( rectBounds, paint )
rectBounds???
formas canvas.drawRoundRect( rectFBounds, radiusX, radiusY, paint )
formas canvas.drawArc( rectFBounds, startAngle, sweepAngle, useCenter, paint )
formas canvas.drawCircle( centerX, centerY, radius, paint )
paths
transformações canvas.save() // faça alguma transformação canvas.restore()
transformações val count = canvas.save() // faça alguma transformação canvas.restoreToCount(count)
translate canvas.translate(deltaX, deltaY)
rotate canvas.rotate(degrees) canvas.rotate(degrees, pivotX, pivotY)
scale canvas.scale(scaleX, scaleY) canvas.scale(scaleX, scaleY, pivotX, pivotY)
skew canvas.skew(skewX, skewY)
clipping (recortes)
clipping (recortes) clipOutPath clipOutRect
clipping (recortes) clipRect clipPath
bitmaps
bitmaps drawables
bitmaps drawables Levels example: https://ryanharter.com/blog/2015/04/03/custom-drawables/
bitmaps drawables custom views
bitmaps drawables custom views item decorators
performance • evite alocações no onDraw • faça clip nas
regiões que não for desenhar • use as ferramentas de profiling para verificar overdraw e debugar quebra de frames
acessibilidade AccessibilityNodeProvider ExploreByTouchHelper
acessibilidade getVirtualViewAt(x: Float, y: Float) getVisibleVirtualViews(virtualViewIds: MutableList<Int>) onPerformActionForVirtualView( virtualViewId: Int,
action: Int, arguments: Bundle? ) onPopulateNodeForVirtualView( virtualViewId: Int, node: AccessibilityNodeInfoCompat )
acessibilidade ????
virtual view data class VirtualView( var id: Int = View.NO_ID,
var contentDescription: CharSequence, val rect: Rect = Rect() )
node provider override fun getVirtualViewAt( x: Float, y: Float ):
Int { val view = virtualViews.find{ it.rect.contains(x, y) } return view?.id ?: HOST_ID }
node provider override fun onPopulateNodeForVirtualView( virtualViewId: Int, node: AccessibilityNodeInfoCompat )
{ val view = virtualViews.find { it.id == virtualViewId } view?.let { node.setBoundsInParent(it.rect) node.contentDescription = it.contentDescription } }
exemplos
backgrounds (itemdecoration) Exemplo: https://github.com/ajarl/item-decoration-sample/blob/master/ app/src/main/java/com/example/itemdecorationsample/ItemDecoration.kt
backgrounds (itemdecoration) Exemplo: https://github.com/ajarl/item-decoration-sample/blob/master/ app/src/main/java/com/example/itemdecorationsample/ItemDecoration.kt
backgrounds (itemdecoration) Exemplo: https://github.com/ajarl/item-decoration-sample/blob/master/ app/src/main/java/com/example/itemdecorationsample/ItemDecoration.kt
histograma Exemplo: https://github.com/mcassiano/custom-drawing
mcassiano
None