Questions tagged [android-canvas]

The Android Java Canvas (android.graphics.Canvas)

This is the tag for the Android Java Canvas, android.graphics.Canvas (official documentation).

If your question is about HTML5 (JavaScript) Canvas on Android devices please tag it and .

3799 questions
1
vote
1 answer

Close two arcs together

I'm designing a custom widget which have a gauge similar to this blue one : (except this is a continuous gauge and not a splited one) I tried to draw a path with two arcs : private void drawGauge(Canvas canvas) { …
Magnas
  • 869
  • 1
  • 5
  • 18
1
vote
1 answer

PorterDuff masking leaves opaque black background

I'm trying to mask a FrameLayout with a mask defined as a nine patch. However, although it works fine on 5.0+ on older versions (such as 4.4.4), the patch leaves an opaque black background. Is there anything that can be done to avoid this other…
Kingamajick
  • 2,281
  • 1
  • 16
  • 19
1
vote
0 answers

Different animation on different display. Android

I have problem with animation in android. My animations working good only on 1080x1920 480dpi display. But i don't know how made app for any display. If I use method from…
1
vote
1 answer

Drawing line numbers with background in Custom android Edittext

I have created a custom EditText class which draws line numbers next on the left of every line. This works fine however I also want to set background of the line numbers to grey and achieve something like this: In onDraw method where I draw the…
John Smith
  • 844
  • 8
  • 26
1
vote
1 answer

How to make last cols and rows same size in custom view

I've created a custom view width grid drawing on canvas. Now my grid rows and cols count depend on actual grid width and height and also fixed cell size(16dp). So if I have grid width=160dp and height=192dp then there will be 10 cols and 12 rows.…
Gleb
  • 1,412
  • 1
  • 23
  • 55
1
vote
1 answer

Speed of sprite on canvas different on different screen sizes

I am using the formula to calculate speed and am using the screen width as distance and fps as time. The speed of the sprite is still different when moving across the screen. How should I change the formula in order to make the speed feel the same…
1
vote
0 answers

Choose from list, then Draw a line Android Studio

My project is about drawing a line on picture, but the user has to choose from the list that provide, then the line will be draw. the line is not similar, so every time the user choose from the list, it has to show different line. I done with…
Sara.Ma
  • 11
  • 1
1
vote
0 answers

Invalidate Custom View when device screen is off

Is there any way to keep invalidating Custom view after regular intervals even when the Screen is Off. I'm working on a music visualizer that renders a plot based on the frequency of the currently playing audio, but if i turn the screen off and turn…
1
vote
0 answers

Bitmap not displaying on canvas

Hi apologies for such a basic question. I've been trying to decode my image resource into a bitmap and draw it onto my canvas within my customView. I've compared this issue to several similar Stackoverflow questions and have tried other methods but…
Patryk
  • 279
  • 1
  • 10
1
vote
2 answers

Android Bouncing Ball using Canvas

This is what i currently have in my MainActivity.java. public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); MyBall ball = new…
Ralph Macalino
  • 121
  • 1
  • 4
  • 13
1
vote
2 answers

How to draw objects on canvas randomly

I have 5 objects that created Randomly after a certain time in a SurfaceView, I draw them on the Draw method like this : bby.draw(canvas); hyd.draw(canvas); hole.draw(canvas); my problem is that the objects won't draw randomly! for E.g : if hyd…
1
vote
0 answers

Is possible to load a canvas that is redrawing in an InfoWindow in android?

I have a probem. I want to draw a thermometer in an Infowindow with temperatures loaded from json. This thermometer has to load the max and min temperatures dinamically. If I do it in a separated proyect it works fine, but when I try to load in the…
1
vote
0 answers

More performant way of drawing predefined path on android custom SurfaceView

I'm struggling to find the best way to draw smoothly as possible some pre-calculated trajectories of physical objects on a custom SurfaceView. So the scenario is like this: I have a 100k entries SQLite database that stores x,y positions of about 10…
bluePhlavio
  • 537
  • 5
  • 18
1
vote
0 answers

Android Crop Bitmap Canvas

I want to create the crop bitmap functionality and have referred Android: Free Croping of Image but this sets the bitmap in another imageView.Now I know I can set the cropped bitmap in the canvas but I want to retain the original bitmap and want to…
zek54
  • 415
  • 3
  • 20
1
vote
2 answers

Memory efficient way to manipulate images?

I have some code that takes two images and merges the middle section of them together into one image. The code works, but uses quite a lot of memory, so it fails on some devices that don't have enough memory. Is there some way to make this code more…
Magnus
  • 17,157
  • 19
  • 104
  • 189
1 2 3
99
100