android-canvas

Android - Fade out bitmap image on canvas

[亡魂溺海] 提交于 2019-12-04 11:02:11
问题 I am drawing a scaled bitmap onto a canvas and would like to fade my image out at a specified time. Basically, when my character image goes over a certain section of the canvas, I require the character image to slowly fade away (3 seconds), before the page automatically re-directs to the next java class. Currently, my image simply redirects to the new java class, please see below some code to how I am creating my image. Resources res = getResources(); float px = TypedValue.applyDimension

Android change canvas background color without losing any drawings from it

谁说胖子不能爱 提交于 2019-12-04 11:01:50
问题 I'm trying to find a way to set background of canvas with a color picked up from custom color picker without removing any drawings on it. I'm trying to create an application which can draw on canvas and than save it as png. But when I set a new background to the current canvas, all drawings are gone. I'm using something like this : mCanvas.drawColor(picker.getColor()); Any ideas how I can get things to work? 回答1: The answers already given to your question are all pointing in the right

How to apply dynamic alpha mask to a Text on Android

守給你的承諾、 提交于 2019-12-04 08:51:25
问题 I want to make a dynamic alpha mask with drawable shapes as circles or whatever, and apply it to a drawed text on Android. Here is an example of what i want : I am trying to make it with setXfermode(new PorterDuffXfermode(Mode.SRC_IN)) , but i can't get it work. Here is the code I have in onDraw(Canvas canvas) method : Paint paint = new Paint(); paint.setAntiAlias(true); canvas.drawARGB(0, 0, 0, 0); paint.setColor(Color.WHITE); canvas.drawCircle(50, 50, 50, paint); paint.setXfermode(new

Android Scaling Canvas Bitmap

僤鯓⒐⒋嵵緔 提交于 2019-12-04 08:38:41
I have a drawing app that allows the user to draw to a blank canvas. I am attempting to draw a scaled 'thumbnail' of the current bitmap so that when the user has scaled in the View, they can reference the thumbnail to get a sense as to where they are in the overall draw canvas. I have the scaling working, and am displaying the thumbnail in the correct location, but it appears that the thumbnail is not being updated on subsequent onDraws when new lines/shapes are added. So that I have access to the underlying bitmap for this view (to show the thumbnail, be able to easily save the bitmap to a

Draw a text on a circle path in android

大兔子大兔子 提交于 2019-12-04 08:37:16
I need to draw a text on a circle path. I have tried the drawTextOnPath() method. But for texts like "fertile window" in the image attched, the text rotates and is not readable. Code I have used : customPath2.addArc(mCircleRectF, 30F, 64.28F); customPaint2.setAntiAlias(true); customPaint2.setDither(true); customPaint2.setStrokeWidth(mCircleStrokeWidth); customPaint2.setColor(Color.parseColor("#93BE66")); customPaint2.setStyle(Paint.Style.STROKE); customPaint2.setStrokeCap(Paint.Cap.ROUND); canvas.drawPath(customPath2, customPaint2); titlePaint.setColor(Color.parseColor("#ffffff")); titlePaint

Android SDK - camera2 - Draw rectangle over TextureView

核能气质少年 提交于 2019-12-04 08:25:26
问题 Im new to android development, and I'm finding it hard to find good examples on the camera2 api. Im working my way slowly through most issues, but on this one I am stuck. In the default camera, when you touch the screen to focus, it shows a rectangle of the focus area for a moment. I want to do something similar (Or in this case, the exact same thing to start off with so i can figure it out). I read somewhere (I think the TextureView page in the SDK docs) that you cant draw on a textureview

how to clear view in android?

笑着哭i 提交于 2019-12-04 07:14:15
I have created a simple demo application in android for drawing ,now can any one say me how can i remove view and clear screen in just one click .I have tried as below:please help me to do it....thanx in advance..! main.java package com.example.singletouch; import com.example.singletouch.R.attr; import android.os.Bundle; import android.app.Activity; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Path; import android.view.LayoutInflater; import android.view.Menu; import android.view.View; import android.view.View

Android - Any library for adding repost label to bitmap

萝らか妹 提交于 2019-12-04 07:12:04
问题 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

Android - Fill Path with color partially

旧城冷巷雨未停 提交于 2019-12-04 06:18:30
I am trying to draw a heart shaped Canvas using Path in Android. The code is as follows : @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); // Fill the canvas with background color canvas.drawColor(Color.WHITE); // paint.setShader(null); // Defining of the heart path starts path.moveTo(left + WIDTH / 2, top + HEIGHT / 4); // Starting point // Create a cubic Bezier cubic left path path.cubicTo(left+WIDTH/5,top, left+WIDTH/4,top+4*HEIGHT/5, left+WIDTH/2, top+HEIGHT); // This is right Bezier cubic path path.cubicTo(left + 3 * WIDTH / 4, top + 4 * HEIGHT / 5, left + 4 * WIDTH

Get Android view as Bitmap to save it on SD

一个人想着一个人 提交于 2019-12-04 06:10:21
问题 I'm trying to save the path that is being drawn on a View but I just can't figure out how to do this. Here is what I'm doing in my Activity to create the View and set it as content: View accPathView = new AccPathView(this, steps); setContentView(accPathView); Then in the onDraw method of my View class, I'm simply creating a path and drawing it on the canvas I received as parameter: But then, when I try to get the bitmap of my view with getDrawingCache(), it's always null and creates an empty