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
83
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
580
Navigation patterns on Android and something new
mcassiano
3
390
Como conseguir o estágio (ou emprego) dos sonhos
mcassiano
0
43
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
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
15
2.3k
Why Jakarta EE Matters to Spring - and Vice Versa
ivargrimstad
0
1.3k
デザインパターンで理解するLLMエージェントの作り方 / How to develop an LLM agent using agentic design patterns
rkaga
9
1.5k
Creating a Free Video Ad Network on the Edge
mizoguchicoji
0
130
Amazon Bedrock Agentsを用いてアプリ開発してみた!
har1101
0
350
見せてあげますよ、「本物のLaravel批判」ってやつを。
77web
7
7.8k
Modular Monolith Monorepo ~シンプルさを保ちながらmonorepoのメリットを最大化する~
yuisakamoto
9
1.3k
Jakarta EE meets AI
ivargrimstad
0
380
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
120
romajip: 日本の住所CSVデータを活用した英語住所変換ライブラリを作った話
sangunkang
0
280
TypeScript Graph でコードレビューの心理的障壁を乗り越える
ysk8hori
3
1.2k
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
130
Featured
See All Featured
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
What's in a price? How to price your products and services
michaelherold
243
12k
Into the Great Unknown - MozCon
thekraken
32
1.5k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
The Cult of Friendly URLs
andyhume
78
6k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
[RailsConf 2023] Rails as a piece of cake
palkan
52
4.9k
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
Site-Speed That Sticks
csswizardry
0
40
RailsConf 2023
tenderlove
29
910
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