android-canvas

how to fix Application not responding?

本秂侑毒 提交于 2019-12-31 00:09:51
问题 i have prepared paint application,my application contains one custom view for paint.when we draw any thing in custom view just collect the drawn pixels and store in array list,first it's working fine(but it's taking lot of time) and second time " Activity MyAlphabets(in application MyAlphabets)is not responding(force close and wait)". My code is, public void onDraw(Canvas canvas) { if (myDrawBitmap == null) { myDrawBitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap

Android- Draw line between two views

妖精的绣舞 提交于 2019-12-30 13:54:28
问题 Below is my program where I have created three new views in a frame. On click of two different views I want to draw a line between the views. I am trying to figure out how to do this... Ball ball1=new Ball(this,100,100,45); Ball ball2=new Ball(this,400,100,45); Ball ball3=new Ball(this,250,350,45); FrameLayout frame1=(FrameLayout) findViewById(R.id.main_view); frame1.addView(ball1); frame1.addView(ball2); frame1.addView(ball3); frame1.setOnTouchListener(new View.OnTouchListener() { public

onClickListener in Canvas

99封情书 提交于 2019-12-30 05:27:05
问题 Im developing an application which having Images as a Index on selection of particular image that activity will begin but I dont know how to set onClickListener or onTouchListener in Canvas heres my code public class DrawView extends View implements OnTouchListener { LinearLayout mLayout; Bitmap index; Bitmap book; Bitmap bird; Bitmap game; Bitmap mail; Bitmap music; Bitmap torch; Paint paint; public DrawView(Context context) { super(context); setFocusable(true); setFocusableInTouchMode(true)

How to get canvas pixel

廉价感情. 提交于 2019-12-30 05:01:13
问题 I have a canvas on which I draw lines: //see code upd I need to make the pipette tool which will take color from my canvas. How may I make it? Code upd: private static class DrawView extends View { ... public DrawView(Context context) { super(context); setFocusable(true); mBitmap = Bitmap.createBitmap(640, 860, Bitmap.Config.ARGB_8888); mCanvas = new Canvas(mBitmap); mPath = new Path(); mBitmapPaint = new Paint(Paint.DITHER_FLAG); this.setDrawingCacheEnabled(true); } @Override protected void

Fill the complete canvas but keep the bound fill area as it is like circle, rectangle

强颜欢笑 提交于 2019-12-28 13:57:43
问题 possible duplicate Hello friends, I creating paint application, I have problem in that. If I draw the rectangle without fill and or another like bound area and change the background color then rectangle fill area also change means whole canvas color will be filled with the new background color. How to keep the background or fill the canvas area which was not bound, here is the image this is the initial image after change the background color getting this result but how to getting like this

Adding a round frame circle on rounded bitmap

对着背影说爱祢 提交于 2019-12-28 11:51:58
问题 Im trying to create a round frame around my bitmap! With this code im able to make my bitmap round: public static Bitmap getRoundedCornerBitmap(Bitmap bitmap) { Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap .getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(output); final int color = 0xff4242DB; final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); final RectF rectF = new RectF(rect); final float roundPx = bitmap

Draw multi-line text to Canvas

拜拜、爱过 提交于 2019-12-27 10:39:24
问题 A hopefully quick question, but I can't seem to find any examples... I'd like to write multi-line text to a custom View via a Canvas , and in onDraw() I have: ... String text = "This is\nmulti-line\ntext"; canvas.drawText(text, 100, 100, mTextPaint); ... I was hoping this would result in line breaks, but instead I am seeing cryptic characters where the \n would be. Any pointers appreciated. Paul 回答1: Unfortunately Android doesn't know what \n is. What you have to do is strip the \n and then

Draw multi-line text to Canvas

不打扰是莪最后的温柔 提交于 2019-12-27 10:38:30
问题 A hopefully quick question, but I can't seem to find any examples... I'd like to write multi-line text to a custom View via a Canvas , and in onDraw() I have: ... String text = "This is\nmulti-line\ntext"; canvas.drawText(text, 100, 100, mTextPaint); ... I was hoping this would result in line breaks, but instead I am seeing cryptic characters where the \n would be. Any pointers appreciated. Paul 回答1: Unfortunately Android doesn't know what \n is. What you have to do is strip the \n and then

how to avoid OUtOfMemory problems with create Bitmap

梦想的初衷 提交于 2019-12-25 19:05:14
问题 I'm trying to create a bitmap from a view with this code : public Bitmap getmyBitmap(View v) { Bitmap b = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888); Canvas c = new Canvas(b); v.draw(c); return b; } But I have an Out Of Memory problems. I can fix it by adding this option to the Manifest file android:largeHeap="true" which is not recommended !! I'm thinking about the recycle of the view ,could be a solution? this is the printStack: 11-25 15:31:46.556 2115-2115

DoubleTap detection on Android “View” component

你说的曾经没有我的故事 提交于 2019-12-25 08:23:05
问题 What I need to achieve here is as following 1) superimpose a transperent "dot" on the PNG image ; where user has clicked. 2) superimpose a transperent "Big circle", when user is holding touch for long. 3) upon Doble click "Clear the screen" Primarily I am using "onTouchEvent" for click-event detection... and "geastureDetector" for doubleTap detection... but not getting the desired result. These are the 2 implementations I am trying out This first approach works fine ... But the click event