android-canvas

cannot see path while moving finger

让人想犯罪 __ 提交于 2019-12-02 20:57:27
问题 Hey I implementing doodling functoinality in my application. While drawing a line I cannot see the line path while moving the finger. I can see the line when is up ie TouchUp, could some one help me so that I can see the line drawn while moving the finger along the path. public class DoodleImageView extends View { // drawing path private Path drawPath; // drawing point private boolean drawPoint; // drawing and canvas paint public Paint drawPaint; public Paint tempPaint; private Paint

GL error from OpenGLRenderer: 0x502

痞子三分冷 提交于 2019-12-02 19:41:13
Our code is performing very simple operations on a Canvas (entirely in UI thread): drawText, translate, save, restore. Occasionally, we get this (on Nexus 4 running 4.3): W/Adreno200-ES20(22118): <gl_draw_error_checks:550>: GL_INVALID_OPERATION D/OpenGLRenderer(22118): GL error from OpenGLRenderer: 0x502 E/OpenGLRenderer(22118): GL_INVALID_OPERATION and the corresponding text is not drawn to the canvas. One problem is that it happens randomly. The code will work without error for maybe 10-20 calls, then there will be this error, then back to working normally for another 10-20 calls before the

Custom Button Background with diagonal Cutting View

半城伤御伤魂 提交于 2019-12-02 18:25:57
I want to set background as shown in image i have tried many tutorial for example https://medium.com/@adinugroho/create-diagonal-cut-view-in-android-5a376eca6a1c https://github.com/florent37/DiagonalLayout but not getting proper result,can anyone help me to get perfect result. Thanks in Advance. UPDATED ANSWER Please do note that you may need to tweak the width and height of the Button to make it work for you. You can do this with vector and layer-list drawables. diagonal_shape <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="150dp" android:height="80dp"

Canvas - zooming in, shifting, and scaling on Android

僤鯓⒐⒋嵵緔 提交于 2019-12-02 17:17:55
I'm currently implementing a draw function on a webview image (the elephant below). I don't have a problem drawing on it but the zoom function does some funky stuff (2nd image below) on the drawing. When I zoom in, the drawing doesn't zoom but rather shifts over. Drawing at zoomed also doesn't work. My code is below: @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.save(); canvas.drawBitmap(canvasBitmap, 0, 0, canvasPaint); canvas.drawPath(drawPath, drawPaint); canvas.scale(mScaleFactor, mScaleFactor); canvas.restore(); clipBounds = canvas.getClipBounds(); }

Drag and move a circle drawn on canvas

北城以北 提交于 2019-12-02 16:24:01
I am working on an Android application which should allow user to draw a circle on canvas and drag it . I have been able to draw lines and circles on it.But I cant seem to be able to drag it. Is it possible to drag an object drawn on canvas in Android?.For example if I detect a touch within the circle, how do I delete the circle from a previous position and move it to the current position? I have tried invalidate() .But it wont work if the user has drawn multiple circle and wants to move all of them. sandrstar It seems that you might have issues with handling of multi-touch / drawing. There's

draw rounded edge arc in android with embossed effect

南楼画角 提交于 2019-12-02 14:41:59
I am trying to develop a custom component i.e. arc slider, I am done with the arc and the thumb but not able to figure out how can I draw the rounded edge arc and also the embossed effect in it. at the moment the slider looks something like this the code for drawing the arc is private void drawSlider(Canvas canvas) { float sweepDegrees = (value * arcWidthInAngle) / (maximumValue - minimumValue); // the grey empty part of the circle drawArc(canvas, startAngle, arcWidthInAngle, mTrackColor); // the colored "filled" part of the circle drawArc(canvas, startAngle, sweepDegrees, mFillColor); // the

android canvas drawText set font size from width?

独自空忆成欢 提交于 2019-12-02 14:06:31
I want to draw text on canvas of certain width using .drawtext For example, the width of the text should always be 400px no matter what the input text is. If input text is longer it will decrease the font size, if input text is shorter it will increase the font size accordingly. Here's a much more efficient method: /** * Sets the text size for a Paint object so a given string of text will be a * given width. * * @param paint * the Paint to set the text size for * @param desiredWidth * the desired width * @param text * the text that should be that width */ private static void

Custom Draw Line Between Two Views Not Working Properly

*爱你&永不变心* 提交于 2019-12-02 13:41:38
问题 I am trying to draw lines between buttons in android. I created one custom class which draw line between buttons inside relative layout(Relative Layout is parent layout). Here is my MatchTheColoumnDrawView.java class which accepts context, startView, endView, lineColour, endCircleColour, thickness(in float), direction(LEFT_TO_RIGHT OR RIGHT_TO_LEFT). import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.DashPathEffect; import

Android - Any library for adding repost label to bitmap

我们两清 提交于 2019-12-02 13:37:32
I have been trying to make a photo sharing app, with the ability to add your image and name to the image. I have been messing with Canvas for the whole day, but couldn't get good results. I was able to draw the name and bitmap, but they didn't look so good. That's why I am here asking about is there any library or piece of code that could help me in making something similar to [this][1]. I wasn't able to find any thing for it. EDIT: Sorry for not adding my own code Here is my code from my latest try public void AddText(Position2D pos){ //Position2D is an enum having the 4 corners of the image

Android subpixel rendering

独自空忆成欢 提交于 2019-12-02 12:01:59
I have a line that should get thinner the longer it gets. The problem is, that you can clearly see a jump when it gets a pixel thinner. Is there a way to do subpixel rendering/antialiasing on Android? canvas.drawRect() takes float values, but it's ignoring those. Here's the code: @Override protected void onDraw(Canvas canvas) { float width = getMeasuredWidth() / (float) getMeasuredHeight() * getMinimumHeight(); float left = (getMeasuredWidth() - width) / 2.0f; canvas.drawRect(left, 0, left + width, getMeasuredHeight(), paint); super.onDraw(canvas); } The paint object has ANTI_ALIAS_FLAG