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
77
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
64
JUnit rules and test parameterization
mcassiano
0
110
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
85
text spans: what, why and how?
mcassiano
0
510
Navigation patterns on Android and something new
mcassiano
3
380
Como conseguir o estágio (ou emprego) dos sonhos
mcassiano
0
43
Databinding e padrão MVVM
mcassiano
1
18
Desenvolvimento móvel: práticas de sucesso
mcassiano
0
24
Other Decks in Programming
See All in Programming
冗長なエラーログを削減し、スタックトレースを手に入れる / Reducing Verbose Error Logs and Obtaining Stack Traces
upamune
0
830
Node.js v22 で変わること
yosuke_furukawa
PRO
9
3.5k
"config" ってなんだ? / What is "config"?
okashoi
0
240
Ruby Function Composition
bkuhlmann
1
330
Code Reviews
bkuhlmann
4
890
Hanami and htmx
bkuhlmann
0
210
Goのmultiple errorsについて (2024年4月版)
syumai
4
980
Goのエラースタックトレースの歴史と今後
sonatard
9
1.6k
TYPO3 v13 – The road to LTS: What's new and new APIs
luisasofie_xoxo
0
210
ONE WEDGE_company_guide
1wedge_one
0
500
Ruby GitHub Packages
bkuhlmann
0
630
PHPはいつから死んでいるかの調査
chiroruxx
1
400
Featured
See All Featured
Why You Should Never Use an ORM
jnunemaker
PRO
51
8.6k
Code Reviewing Like a Champion
maltzj
514
39k
The World Runs on Bad Software
bkeepers
PRO
61
6.7k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
17
1.4k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
30
6k
Bootstrapping a Software Product
garrettdimon
PRO
302
110k
Intergalactic Javascript Robots from Outer Space
tanoku
266
26k
For a Future-Friendly Web
brad_frost
172
9k
[RailsConf 2023] Rails as a piece of cake
palkan
23
4k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
155
14k
How To Stay Up To Date on Web Technology
chriscoyier
782
250k
The Cost Of JavaScript in 2023
addyosmani
16
3.9k
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