Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
unraveling custom drawing
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Matheus Cassiano Candido
August 07, 2018
Programming
96
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
unraveling custom drawing
Matheus Cassiano Candido
August 07, 2018
Transcript
44 slides
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
More Decks by Matheus Cassiano Candido
See All by Matheus Cassiano Candido
Kotlin Static Analysis - Kotlin Everywhere 2019
mcassiano
0
130
JUnit rules and test parameterization
mcassiano
0
150
The Basis of Android Threading: Loopers and Handlers
mcassiano
1
150
Hackeando sua próxima entrevista: dicas para conseguir seu próximo estágio ou emprego
mcassiano
1
110
text spans: what, why and how?
mcassiano
0
720
Navigation patterns on Android and something new
mcassiano
3
430
Como conseguir o estágio (ou emprego) dos sonhos
mcassiano
0
59
Databinding e padrão MVVM
mcassiano
1
37
Desenvolvimento móvel: práticas de sucesso
mcassiano
0
37
Other Decks in Programming
See All in Programming
SODA - FACT BOOK(EN)
sodainc
1
280
Lean で手続き的プログラム の証明が書けるようになった
inoueasei
0
120
手の動かし方がわからなかった私が個人開発者になるまで
usagi0920_pochi
0
340
Crash Auto Pipelines
veronikapj
1
450
Goコンパイラを作ってGoをもっと理解する / Build a Go compiler to better understand Go
ikura_hamu
0
140
TS 7.0 で baseUrl が使えなくなった今、パスエイリアスをどうするか
bicstone
2
820
AIが実装を担う時代の「技術設計」と「チームマネジメント」
kamina_zzz
2
450
自宅サーバはどこまで再現できるのか - Proxmox VE上のVM環境をIaCとバックアップで戻してみた
youto
0
450
Skills Are the New npm [AAIF Bengaluru, Nov 2026]
shivamsaraswat
0
130
複数ドメインを一つのアプリに統合するFlutterの設計と運用_FlutterKaigi2026登壇資料(須永高弘)
takahirosunaga
0
210
社内AIエージェント「Askワンバン」における コストチューニングの取り組み
t0yohei
0
180
Proxmox x Talos Linux x Terraform で実現するなんかいい感じの Kubernetes クラスタ / A Sleek Kubernetes Cluster Powered by Proxmox, Talos Linux, and Terraform
nnaka2992
0
310
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
96
6.9k
Scaling GitHub
holman
464
140k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
500
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
2
3k
Balancing Empowerment & Direction
lara
6
1.4k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
48k
Git: the NoSQL Database
bkeepers
PRO
433
67k
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
Amusing Abliteration
ianozsvald
1
400
Why Our Code Smells
bkeepers
PRO
340
58k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
470
Chasing Engaging Ingredients in Design
codingconduct
0
410