android-canvas

Draw quarter gauge with canvas in android? [closed]

微笑、不失礼 提交于 2019-12-23 05:14:40
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . How can I create gauge same as this? any library or maven exist for this gauge type? I use canvas for circle gauge ,but I can't create this one RectF oval = getOval(canvas, 1); RectF oval2 = getOval(canvas, 1.1f); Paint paint = new Paint(); paint.setColor(Color.DKGRAY); canvas.drawArc(oval2, 180, 90, true, paint

Pan, Zoom and Scale a custom View for Canvas drawing in Android

偶尔善良 提交于 2019-12-23 03:22:40
问题 I'm working on a drawing app, where the user can pan & zoom to a specific portion of the screen and start drawing with zoom applied. To be more specific, I'm looking for a way to implement zoom, pinch & pan gesture in Canvas (horizontal and vertical scrolling with moveable x, y coordinates). Right now, I've successfully developed the zoom only feature but it's not accurate and the pan option is not working. See my sample code here, public class DrawingView extends View { //canvas private

Draw Rectagle with fill outside bounds

寵の児 提交于 2019-12-23 03:13:37
问题 I am drawing an Rectangle with outside of rectangle fill. I tried some of this. But cant get the perfect one what i expected. This is what i expected. I tried Point pTopLeft = new Point(); Point pBotRight = new Point(); pTopLeft.x = 100; pTopLeft.y = 100; pBotRight.x = canvas.getWidth() - 100; pBotRight.y = canvas.getHeight() - 100; Rect above = new Rect(0, 0, canvas.getWidth(), pTopLeft.y); paint.setColor(Color.parseColor("#77000000")); canvas.drawRect(above, paint); Rect left = new Rect(0,

Android - Draw text with solid background onto canvas to be used as a bitmap

那年仲夏 提交于 2019-12-23 02:34:17
问题 I've built an app that draws text with a boarder onto canvas that is then used as a bitmap and put into a google maps marker. What I would now like to do is remove the text boarder and create a solid black rectangle background behind the text instead. I've tried a couple of things but can't seem to get anything working on screen. Code so far: String text = "testText"; //create bitmap Bitmap.Config conf = Bitmap.Config.ARGB_8888; Bitmap bmp = Bitmap.createBitmap(300, 100, conf); //--style text

how to overlay one bitmap to another and save on sdcard

心已入冬 提交于 2019-12-23 02:01:29
问题 i am developing image editor and im using custom class to draw bitmap, here is my code.. private void settingBitmapToDraw() { // TODO Auto-generated method stub resultBitmap=Bitmap.createScaledBitmap(resultBitmap, WIDTH, HEIGHT, true); Matrix matrix=new Matrix(); matrix.setRotate(TO_DEGREE); tempBitmap=Bitmap.createBitmap(resultBitmap, 0, 0, WIDTH, HEIGHT, matrix, true); bitmap=Bitmap.createBitmap(WIDTH, HEIGHT, tempBitmap.getConfig()); canvas=new Canvas(bitmap); invalidate(); } protected

Make Screen Compatibility Containing Canvas

给你一囗甜甜゛ 提交于 2019-12-23 01:18:17
问题 I am working with canvas in android. i want to draw shapes on canvas which fits in every screen. if screen size is 320 * 240 then height & width with is 90 * 90 but if screen_size is > 320 * 240 then it should increase accordingly. Suppose screen_size = 1280 * 800 then how much it should increase I don't know what to do for this Code is Like int fixHeight = 240, fixWidth = 320; Paint paint; paint = new Paint(); paint.setColor(Color.GREEN); DisplayMetrics displaymetrics = new DisplayMetrics();

Draw a circle partially filled dynamically

≡放荡痞女 提交于 2019-12-22 18:48:08
问题 I'm trying to play with canvas. I could draw some triangles and fill it partially drawing a path and paint it.I used Path, Points and Line. It was a great exercise to remember trigonometry. For now I would like to do the same with a circle, as you can see below. I want set a percentage and to fill this circle until the circle's height * percentage. How could me draw a circle like that with canvas or some lib? 回答1: You should think about it a little differently. The way I'd do it is to draw a

How to set an image to fill a canvas

試著忘記壹切 提交于 2019-12-22 18:00:04
问题 I am trying to set a png image to fill the background of my canvas while still maintaining its aspect ratio. I start by converting it to a Bitmap:Then set the back ground using the setBitmap method from the Canvas class: http://developer.android.com/reference/android/graphics/Canvas.html#Canvas(android.graphics.Bitmap) public class PlayOn extends View{ Bitmap board; public PlayOn(Context gamecontext) { super(gamecontext); board=BitmapFactory.decodeResource(getResources(),R.drawable.board_rev1

Android Photo Background Eraser need help- Not erasing bitmap but just draws black lines

只谈情不闲聊 提交于 2019-12-22 13:55:18
问题 I am developing 1 app in that i need to erase the Bitmap for that i have done is.... (code is working but just draw black lines..) @Override protected void onDraw(Canvas canvas) { canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint); for (PathPoints p : paths) { mPaint.setColor(p.getColor()); mPaint.setXfermode(new PorterDuffXfermode(Mode.CLEAR)); Log.v("", "Color code : " + p.getColor()); if (p.isTextToDraw()) { canvas.drawText(p.textToDraw, p.x, p.y, mPaint); } else { canvas.drawPath(p.getPath(),

Android: Draw a view on canvas

我只是一个虾纸丫 提交于 2019-12-22 06:59:03
问题 I have a view inflated, I can draw it on canvas, but can't seem to position it properly. LayoutInflater li = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = li.inflate(R.layout.fix_this_recommendation, null); v.measure(MeasureSpec.getSize(v.getMeasuredWidth()), MeasureSpec.getSize(v.getMeasuredHeight())); v.layout(400, 400, 400, 400); v.draw(canvas); But the view is always at the top left corner. Anyone know why? 回答1: Each View draws its contents within its