android-canvas

Draw a circle within circle at a distance of 10

夙愿已清 提交于 2019-12-02 11:28:09
I have recently started working with Android, And I need to draw a Circle within Circle just like below image at a distance of 10. If you see the below photo, I need to draw something like below circle with two diameters like that and I don't need any icons that are there currently on the photo. Just a Circle within Circle having two diameters. I want to draw only the circles and two diameter, not the icons on the circle. Any suggestions will be appreciated. Update:- I wrote the below code but it draws only one circle. I need to draw like the image above- public void onCreate(Bundle

android live wallpapers parallax-scrolling effect

风格不统一 提交于 2019-12-02 11:22:28
when we scroll, the foreground of the home screen (icons, widgets, etc.) moves to the left or right by the full screen width, but the background image (or live wallpaper) only moves by a fraction of that width. My question is how get this effect. till now have done this. SurfaceHolder holder = getSurfaceHolder(); Canvas canvas = null; try { canvas = holder.lockCanvas(); if (canvas != null) { drawCircles(canvas); } } finally { if (canvas != null) holder.unlockCanvasAndPost(canvas); } the draw function is { private void draw(Canvas canvas) { Paint paint = new Paint(); DisplayMetrics

creating a random circle that can be clicked on like a button

空扰寡人 提交于 2019-12-02 11:18:06
so here is my predicament i cannot seem to find this anywhere on the internet. My question is simple. I am creating a game app for android. The game will generate random circles on the screen that a user can click on then once the user does click on one of these random circles an action will occur. This is just like the function of the button, but different because the whole circle will be able to be clicked. i will post the random number generator that generates the circles this is not the main class this is a seperate class that extends view. public class DrawingView extends View { public

Android: Draw text on ImageView with finger touch

≯℡__Kan透↙ 提交于 2019-12-02 11:11:01
问题 i completed the drawing text on ImageView and i saved the final image in sd card. My problem is, when i am touching the screen to draw the text, my image in the ImageView is disappearing. Code import java.io.File; import java.io.FileOutputStream; import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.os.StrictMode; import android.annotation.SuppressLint; import android.app.Activity; import android.content.Intent; import android.graphics.Bitmap; import

Generate a circle randomly on the screen and make it green or red

余生长醉 提交于 2019-12-02 10:23:22
问题 So ive been trying to make a game app that either displays a red button with text or a green button with text randomly on the android screen. If anyone can help me with this i would appreciate it. also on a side note i want to slowly generate faster cool upside if anyone knows how to do that. Thanks! @SuppressLint("DrawAllocation") @Override protected void onDraw(Canvas canvas){ String str = "Joke of the day"; super.onDraw(canvas); paint = new Paint(); Random random = new Random(); Random

cannot see path while moving finger

自作多情 提交于 2019-12-02 10:14:29
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 canvasPaint; // initial color private int paintColor; // canvas private Canvas drawCanvas; // canvas bitmap

Bug in Canvas.drawVertices? (with repro code and logcat)

僤鯓⒐⒋嵵緔 提交于 2019-12-02 07:43:56
Simply paste this code into a simple skeleton Android project. public final class DrawableView extends View { private float[] mVertices = {0, 0, 255, 0, 255, 255, 0, 255}; private float[] mTexCoords = {0, 0, 255, 0, 255, 255, 0, 255}; private short[] mIndices = {0, 2, 3, 0, 1, 2}; private int[] mColors = {Color.RED, Color.GREEN, Color.BLUE, Color.MAGENTA}; Context mContext; BitmapShader mShader; public DrawableView(Context context) { super(context); mContext = context; mShader = new BitmapShader(BitmapFactory.decodeResource(getResources(), R.drawable.icon), Shader.TileMode.CLAMP, Shader

Draw a line on ImageView set by Picasso

故事扮演 提交于 2019-12-02 07:25:32
I am trying to figure out how to simply draw a line on an image that is being set in Picasso. I found that if I simply set the image, given a URI, with Picasso and try to draw paint to it using the following: canvas = new Canvas(bitmap); image.draw(canvas); topEdge = new Paint(); topEdge.setColor(context.getResources().getColor(R.color.blue)); topEdge.setStrokeWidth(5); canvas.drawLine(c1.getX(), c1.getY(), c2.getX(), c2.getY(), topEdge); Then I get a crash saying that the bitmap needs to be mutable first. So I added this above that code: Bitmap workingBitmap = ((BitmapDrawable) image

Android merge two images

我怕爱的太早我们不能终老 提交于 2019-12-02 07:12:19
I want to merge two images and then save them on the Android SDCard.One is from the camera and one from the resources folder. The problem is that i get this error: Caused by: java.lang.IllegalStateException: Immutable bitmap passed to Canvas constructor. Thanks. Bitmap bottomImage = BitmapFactory.decodeResource(getResources(),R.drawable.blink); Bitmap topImage = (Bitmap) data.getExtras().get("data"); // As described by Steve Pomeroy in a previous comment, // use the canvas to combine them. // Start with the first in the constructor.. Canvas comboImage = new Canvas(bottomImage); // Then draw

Bug in Canvas.drawVertices? (with repro code and logcat)

China☆狼群 提交于 2019-12-02 06:48:33
问题 Simply paste this code into a simple skeleton Android project. public final class DrawableView extends View { private float[] mVertices = {0, 0, 255, 0, 255, 255, 0, 255}; private float[] mTexCoords = {0, 0, 255, 0, 255, 255, 0, 255}; private short[] mIndices = {0, 2, 3, 0, 1, 2}; private int[] mColors = {Color.RED, Color.GREEN, Color.BLUE, Color.MAGENTA}; Context mContext; BitmapShader mShader; public DrawableView(Context context) { super(context); mContext = context; mShader = new