Is android.graphics.Paint memory heavy object? Which one is more efficient, to pass paint object refrence to classes that need to draw on canvas and set paint properties such as color, style, etc. in those classes, or create new Paint object wherever it's needed?
Android Paint Object Memory Efficency
1.7k views Asked by Thracian At
2
There are 2 answers
1
Vova
On
For me best way is: Create new Paint for each object with different style or width or color. And for draw text create other paints. (If you want draw to text with different color or text size create new paint to)
This way create your code more lazy for other developer, because one paint draws one object, it is good OOP style ))).
Related Questions in ANDROID
- Creating global Class holder
- Flutter + Dart: Editing name of a tab shows up a black screen
- android-pdf-viewer Received status code 401 from server: Unauthorized
- Sdk 34 WRITE_EXTERNAL_STORAGE not working
- ussd reader in Recket Native module
- Incorrect display of LinearGradientBrush in IOS
- The Binary Version Of its metadata is 1.8.0, expected Version is 1.6.0 build error
- I can't make TextInput to auto expand properly in Android
- Creating multiple instances of a class with different initializing values in Flutter
- How to create a lottie animation
- making android analyze with coverity sast tool
- Flutter plugin development android src not opening after opening example
- I initialize my ViewModel in the Activity with several fragments as tabs, but the fragments(tabs) return null for the updated livedata
- Node.js Server + Socket.IO + Android Mobile Applicatoin XHR Polling Error...?
- How I can use the shared preferences class?
Related Questions in PERFORMANCE
- Upsert huge amount of data by EFCore.BulkExtensions
- How can I resolve this error and work smoothly in deep learning?
- Efficiently processing many small elements of a collection concurrently in Java
- Theme Preloader for speed optimization in WordPress
- I need help to understand the time wich my simple ''hello world'' is taking to execute
- Non-blocking state update
- Do conditional checks cause bottlenecks in Javascript?
- Performance of sketch drastically decreases outside of the P5 Web Editor
- sample query for review for improvement on big query
- Is there an indexing strategy in Postgres which will operate effectively for JOINs with ORs
- Performance difference between two JavaScript code snippets for comparing arrays of strings
- C++ : Is there an objective universal way to compare the speed of iterative algorithms?
- How to configure api http request with load testing
- the difference in terms of performance two types of update in opensearch
- Sveltekit : really long to send the first page and intense CPU computation
Related Questions in ANDROID-CANVAS
- BlendMode does not work as expected with a path and circle in Jetpack Compose
- How to draw image in canvas compose without stretching the image
- How to skew the x axis labels in canvas in Kotlin
- Create a VideoFrame from Canvas
- How to center an image on canvas after rotate the image (Konva.js)
- Android Canvas onDraw and Resize When ViewGroup was changed size ( synchronize )
- Image to Bitmap conversion with MLKit returns null
- Canvas.drawBitmap() fails on Android 9 device
- How to match Android Canvas to A3 paper size?
- Canvas Drawing conversion to DWG/DXF
- How to pick the Color code from a position in Android Linear Gradient?
- Android: How to scroll a closed path
- Jetpack Compose - best way to handle pixel-exact composables with pointer input
- How to overlap two path figures on Canvas?
- When the update occurs on Android TV, canvas seems to expand
Related Questions in ANDROID-PAINT
- How to skew the x axis labels in canvas in Kotlin
- How does TextView display (changes to) its text?
- How to use android canvas to draw a striped rectangle?
- Android Bitmapshader separating the colors of a two-color bitmap
- Android. How to paint all area around of rectangle?
- Android Paint. How is the character width calculated?
- How to draw four boundary corner in canvas for qr code scanner
- use custom font in paint object typeface field
- java.lang.NoSuchMethodError: No virtual method getTextBounds Error in android
- Android screen collaboration between devices
- Masking inputted text using canvas on android kotlin
- canvas drawText and emoji alpha color
- How to draw the same png icon in different colors?
- Can not set image resource of a custom imageview in Android
- How Android Zoom works properly?
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Yes,
Paintis heavy, especially its creation and initialization. Does this mean you have to reuse the samePaintobject for everything? Well, it depends.If you are going to perform multiple
drawText()but with different color, then you can reuse the same paint but with different color (usingsetColor()). But if you are going to perform two unrelated operation(drawing) in two different classes and there are major differences in the Paint configuration like Color, font size, Style, PathEffect, etc... then it's better to have separate Paint objects for them.In short, use the same paint for performing similar drawing with less differences. And use different paint objects for performing unrelated drawing with major differences. Hope this helps.