Questions tagged [android-canvas]

The Android Java Canvas (android.graphics.Canvas)

-3
votes
0answers
19 views

Android Canvas with segments

I created custom Canvas.Here is a my code snippet float startAngle = 270 - arcAngle / 2f; float finishedSweepAngle = progress / (float) getMax() * arcAngle; float finishedStartAngle = ...
0
votes
0answers
19 views

Where should I use canvas with?

I want to juggle and manipulate several (3, to be more precise) bitmaps and generate smooth animation (hardware acceleration would be required) My reading on this subject so far led me to believe ...
0
votes
0answers
17 views

How can we track object which on Path in android?

I have to create auto edge detection in form of android Drawing Path. I was used to path measure it is taking much time. and unuseful method.
0
votes
0answers
20 views

How to find android canvas width before instantiating the canvas object?

I was creating a printdocumentadapter class to generate pdf to print. I needed to automatically calculate how many pages I was going to need based off my data variable(which is just a string ...
-1
votes
1answer
56 views

Wrong coordinates after scaling canvas

We have the red dot in (100; 100) coordinates. If we click to red dot after dragging - it will save it's (100; 100) coordinates. But if we scale in or out it will have coordinates completely different ...
0
votes
1answer
13 views

Drawing light arc on top of dark arc makes lower arc partially visible

I am making android custom view, which is supposed to be loading animation(spinning arc), my view allows developer to set background color and top color. The problem is that when I draw light colored ...
0
votes
1answer
23 views

Drag a rectangle on Canvas Android

I'm drawing a rectangle on a Canvas in Android. How do I drag it around on the screen? I have an onTouchEvent() method in my class that listens to MotionEvent(s). How do I use this to drag my ...
0
votes
0answers
25 views

Drawing a continuously rotating square in Android

I want to draw a square on the screen on an Android Device and want the square to rotate continuously every one second. I'm drawing the square using a custom View class. But when I call rotate on the ...
-1
votes
1answer
35 views

How to adjust an overlay location in response to PhotoView zoom/pan

I am using chrisbanes/PhotoView library to handle image zoom/pan. I am displaying an overlay on top. Basically, I add a view on top of the image view at specific coordinates. For example, I add a ...
0
votes
1answer
20 views

Custom canvas artifacts being shown despite using drawColor()

I've created a custom view that draws a dial gauge. If I set a static value for the angle of the needle, the gauge draws as expected (see first image below). If I attempt to set the angle of the ...
0
votes
0answers
36 views

I want to overlay two bitmaps on a canvas and produce a single bitmap. But the second image is much smaller than its original size

I want to overlay two bitmaps on a canvas and produce a single bitmap in android. but second image is much small as its original size. But second image or small image is looking more small on canvas ...
1
vote
1answer
32 views

Android canvas image with user's current gps location?

I am working on an android application that needs to keep track of a person's gps loaction inside a rectangular area (say 500X600 meters). I don't want to view the location on google maps or osm ...
0
votes
1answer
35 views

how to make custom view dial drawing numbers with trigonometry

Im trying to create an custom view that displays a dial with the numbers 1-10 around it. Im using trigonometry to find the X and Y positions for the numbers of the dial. I have no problems to find the ...
0
votes
1answer
28 views

How disposable are Canvas objects?

Imagine I have a Bitmap and I need to draw on it. For that I need to wrap it in a Canvas. Can I wrap it as follows: Bitmap mBitmap; public void drawDrawable(Drawable d){ d.draw(new Canvas(...
0
votes
0answers
15 views

Canvas - zooming in, shifting, and scaling on PDF view

I'm currently implementing a draw function on a PDF view . I don't have a problem drawing on it but the zoom function does some funky stuff on the drawing. When I zoom in, the drawing doesn't zoom ...
0
votes
0answers
45 views

Android : imgView.getDrawingCache() crops the Bitmap when I save in the storage

I am adding a point on Canvas bitmap. Scale, Rotate and Move gestures are enabled on the ImageView. After that, I am saving the image in the external storage through a button click. But the bitmap is ...
1
vote
0answers
44 views

In Android, when I draw a point on the Canvas, it doesn't stay on the Bitmap when I move, scale or rotate the Bitmap

My app has two buttons. One for selecting image from the storage and loading it to an ImageView. I do that using Picasso library. The other button is drawing a point on the Canvas. I have attached ...
5
votes
1answer
120 views

WallpaperService Image Drawing Performance

I am working on a livewallpaper for Android. The code works, but I have performance issues. Basically I am drawing Bitmaps and move them. With 15 small images it workes fine. But with 50 bigger images ...
0
votes
0answers
39 views

How to make sweepGradient to start applying from the top of a circle in flutter?

I want to create something like this in flutter. Here is my code import 'package:flutter/material.dart'; import 'dart:math'; class Arc extends CustomPainter { final double angle = 210.0; double ...
0
votes
1answer
38 views

How to Draw Rounded Rectangle in API Level below 21 on a Canvas

I am creating a custom view by extending android.view.View. Now, I need to draw a rounded rectangle on API level below 21. Android has a built in method name,drawRoundRect(float left, float top, ...
0
votes
0answers
16 views

CircleTransform Not working with Picasso on android P

I am using the widely used CircleTransform for achieving circular image with latest public release of Picasso(2.71828). It works fine for pre Pie versions but in my Android P emulator, Picasso can't ...
-1
votes
1answer
43 views

Getting imageView null reference error - why so?

I'am drawing a re-sizeable rectangle on a image view. The View class to draw the custom re-sizeable rectangle view: public class DrawPolygonCanvas extends View implements OnTouchListener { ...
0
votes
1answer
25 views

Problematic clip already set on Canvas in onDraw

I subclassed TextView to provide a custom onDraw. But canvas has a clip region applied that is nonsensical: the x is set to something well outside the view bounds. I think that's thwarting my purposes....
0
votes
0answers
27 views

Put a shader on Drawable

I have a shader that simulates distortion with horizontal lines. Shader yellowShader = new LinearGradient(0, 0, 0, 5, Color.BLACK, Color.WHITE, Shader.TileMode.REPEAT); I put this shader on Paint to ...
2
votes
0answers
24 views

How to undo transparent drawing?

I develop a drawing application. I need to implement undo and redo actions. It is necessary to implement undo by drawing same stroke over undoing stroke but with special paint. There are my paints for ...
-1
votes
1answer
36 views

how to correctly compare coordinates?

I have custom view with drawn text and with user drawn line. Text have some (x,y) coordinates and line have it as well (as soon as user draws it). And I just want to compare, that line coordinates ...
0
votes
2answers
17 views

Render preview of layered png images

I want to render preview of a layered image All the images and text with the x any y coordinates are known from photoshop I want to place all images at thoose positions . Any Idea Or Any Available ...
0
votes
1answer
25 views

Programmatic scroll of Webview isn't reflected when drawing from Canvas

I'm extracting frames from a WebView in it's draw method and scrolling it programmatically. The problem is, no matter how big my bitmap is, I only get the output from the WebView based on its initial ...
-3
votes
1answer
29 views

Is there any way to get vector pathData prorgamatically and draw shape using that pathData in canvas?

i have world map xml file which i imported in android studio.and want to get path data of countries dyanmically. How can i achieve this.After getting the pathData i want to plot that points in ...
0
votes
0answers
23 views

After device rotation, Painting position changes automatically in the custom view in android

I have made a custom view for drawing on canvas. I am able to draw painting in the canvas but it's position changes after rotating the device. I can not afford to fix device orientation. In portrait ...
0
votes
0answers
32 views

How to draw image from SVG path points through canvas in android and set image inside the drawn shape

i want to draw shape threw SVG path point. i am able to get path points from SVG image but i am not able to draw it through canvas. if any body has any idea how to do it please help me. i am stuck at ...
0
votes
1answer
31 views

How to save edited image with original resolution?

=> We have create one image editor. But, i have save edited image then image resolution is down. => My save method is: bitMap.compress(Bitmap.CompressFormat.PNG, 100, stream); => Any idea for save ...
0
votes
0answers
16 views

Rectangle on canvas with stroke having color changing in a transition animation from one color to second and so on

I want to draw a rectangle using canvas which has a stroke with gradient color, and it has a color changing transition animation -> it goes from one color to second and second to 3rd color and 3rd to ...
0
votes
1answer
29 views

Invert the canvas' drawText()

Been looking for a way to invert the text when I draw the texts on my canvas object. I could not find any related problem here in SO. (Maybe I am using the wrong keywords.) This is what I want to ...
0
votes
0answers
59 views

Smooth shape shifting animation

How to implement smooth shape shifting animation in android ? I'm rendering polygon shapes on camera preview using canvas.draw(path, paint) in OnDraw() method of my custom view. The path is being ...
0
votes
1answer
22 views

Swipe to exit immersive mode is picked up by canvas touch events

I have a SurfaceView that uses a canvas to render based on touch events. The activity also uses immersive mode to make it full screen. The problem is that when the user swipes from the top of the ...
0
votes
0answers
38 views

How Do I set the size of a canvas to the size of a background Image?

So I am trying to develop a drawing app. I would like to know if and how it would be possible to set the size of a canvas that the person can draw on to the size of a transparent image. Eg: I want to ...
0
votes
1answer
24 views

Android canvas: Is it possible to add images from gallery?

In some paint apps or note taking apps, they will allow you to add text and images in addition to drawing stuff. Now I know that I can create a custom view and override on touch events and build ...
0
votes
1answer
21 views

Colour outside a box in Android, while keeping the box transparent?

I have a box in my Android application, which needs to be transparent, while filling the rest of the frame outside the box with a specific colour. How exactly could this be done in Canvas or OpenCV ...
0
votes
0answers
11 views

Cant zoom to pinch points : android

I entered a zoom code and it has zoom but it zooms to the 0,0 coordinates. I want to zoom in to the pinch points, what do I need to do? What changes are needed in terms of scale?
0
votes
1answer
37 views

How to draw line on top of the vertical seekbars?

I'm building an music player app. For the equalizer design, I am using five vertical seekbars. Now I want to add a line on top of those seekbars like shown in this image. The line will be connected ...
0
votes
2answers
28 views

Is there any way to create class which extends from Canvas in Android?

I'm trying to create a class that inherits Canvas class of Android. My reason is adding more robust and useful methods to that class for my game framework. When I tried to cast my AdvancedCanvas ...
1
vote
0answers
28 views

How to draw the text vertically in Pie Slice?

I Need to make Pie chart like below images and there slice text should be vertically (start text near radius to out) small slice text
0
votes
0answers
9 views

Preserver line thinkness during canvas draw android

I am trying to preserve line thickness and dash path effect with following line Paint code but when scaling grow Inside onDraw() mCanvas?.save() mCanvas?.scale(scaleFactor,scaleFactor,...
1
vote
1answer
24 views

Is there any way to rotate a PDF file created using PdfDocument canvas in android

Is there any way to rotate a PDF file created using PdfDocument canvas in android or is there any way to rotate a pdf file before saving to phone on android ?
1
vote
1answer
25 views

Cannot redraw the hall seat using Canvas in android

I have the requirement to create hall seat which consists more than 1200 seats. I searched on google and found one library which meet my requirement (Link : SeatTable). We used Socket.io for realtime ...
-2
votes
1answer
29 views

Hall Seat Layout Design Android

How to make hall seat that contains more than 1200 seats in android? For references design please look at below image. Please guide me.
0
votes
0answers
23 views

How to make TextSticker background the same size as the size of text in StickerView?

I'm developing an app right now using https://github.com/wuapnjie/StickerView which uses a transparent drawable background for text stickers. I want the background to be the same size as the size of ...
0
votes
0answers
43 views

Is it possible to draw shapes on (a) canvas in multiple threads java (android)

I have a game that should draw many shapes on the canvas and in every frame these shapes position will change, the game running smooth but after adding more shapes some jank arise up and it drops some ...
0
votes
0answers
34 views

StaticLayout with fuzzy emojis and symbols below

I'm working on an Android app that creates a pdf containing an image and a text the user typed. The pdf is created with PdfDocument lib. When the title string contains emojis, the application ...