When trying to make a gradient from the background, the background is filled with one color

All we need is a simple explanation of the problem, which is provided below. I’m creating an Android application and I needed to create a Drawable with a gradient background and text inside, but for some reason I don’t have a gradient, and the entire background is filled with solid color Class code: class TestDrawable(textSize: … Read more

How to handle screen orientation in Canvas of Android?

All we need is a simple explanation of the problem, which is provided below. I am working with Canvas in Android and the issue I am facing is during the screen rotation. Let’s say I start the app in portrait mode and draw something on the canvas, then on rotation some part of the canvas … Read more

How to draw using the SKIA C++ API on a Java Canvas object on Android?

All we need is a simple explanation of the problem, which is provided below. I am experimenting with native drawing using the Java Canvas API on Android. As far as I can understand, Canvas is built as an abstraction on top of SKCanvas from the Skia graphics engine. I’m willing to pass the Canvas object … Read more

Jetpack Compose semicircle using Canvas

All we need is a simple explanation of the problem, which is provided below. I am trying to create a semicircle speed progress bar in Jetpack Compose. Unless the view is square the semicircle will not look as expected, if I use 1:2 width: height it will be flattened. I want a Composable representing half … Read more

how to draw a square with stroke and neon glow with Jetpack Compose Canvas?

All we need is a simple explanation of the problem, which is provided below. I need to draw a rounded square, something like drawRoundRect, but only the outline. something like this. this image is drawn by hand, as I said I need it to look like drawRoundRect but without outline (I don’t want it to … Read more

Creating bitmap from canvas java

All we need is a simple explanation of the problem, which is provided below. SOLUTION Thanks to @ChandraSekhar’s suggestions the issue was that I was passing in an Immutable Bitmap to the canvas constructor. The solution is to create a copy of it when using BitmapFactory.decodeFile(); Bitmap bmp = BitmapFactory.decodeFile(imageURL).copy(Bitmap.Config.ARGB_8888, true); So I have a … Read more

Android SurfaceView not retaining previously drawn objects

All we need is a simple explanation of the problem, which is provided below. I am experimenting with SurfaceView. My requirement is to simply render a node (simple drawable) first. Then, render more nodes at a later point in time. The snippets of my thread’s run method & my doDraw method are below. I am … Read more

DoubleTap detection on Android "View" component

All we need is a simple explanation of the problem, which is provided below. What I need to achieve here is as following 1) superimpose a transperent “dot” on the PNG image ; where user has clicked. 2) superimpose a transperent “Big circle”, when user is holding touch for long. 3) upon Doble click “Clear … Read more