android-canvas

Draw text vertically on canvas

风格不统一 提交于 2019-11-29 07:35:06
I would like to learn how to draw vertical text on the canvas. Sorry for maybe stupid question, but I can not solve this problem. I can do so: if (i ==10) { this_str2 = "0.00"; } canvas.save(); canvas.rotate(-90,190,90); canvas.drawText(this_str2, x_guide +50, drawSizes[1] + drawSizes[3] - (i * drawSizes[3] / 10) +20, paint); canvas.restore(); } But it is not properly displayed on the X and Y is any other solution to this problem 7 Try this custom textview, I don't remember where I took if from (here in StackOverflow), if any one remembers, please post a link in the comments. import android

Creating a drawable & zoomable image view in android

Deadly 提交于 2019-11-29 05:54:04
问题 Goal: Create an imageview that is drawable and zoomable, That means when I press a button to on , it is drawable, or when I turn off, that is zoomable. *Notice the drawings should zoom align with the imageview =============================================================== Recently I wrote a custom drawable image view like this: public class DrawView extends ImageView { private int color = Color.BLACK; private float width = 4f; private List<Holder> holderList = new ArrayList<Holder>();

Android Implement onTouchListener on path objects

别说谁变了你拦得住时间么 提交于 2019-11-29 05:19:48
I have created a path objects as shown below which draws a different shapes.Different buttons response to drawing different shapes on the canvas. I would like to shift the path objects that i have created in the canvas but I do not know how to. I only know the method of implementing ontouchlistener on a bitmap and not on path objects. my codes are as follows: ArrayList<Path> paths = new ArrayList<Path>(); @Override protected void onDraw(Canvas canvas) { // TODO Auto-generated method stub super.onDraw(canvas); paintColor.setColor(Color.RED); paintColor.setStrokeWidth(2); paintColor.setStyle

Canvas.drawTextOnPath(…) not working on Lollipop

丶灬走出姿态 提交于 2019-11-29 04:19:08
canvas.DrawTextOnPath does not seem to work on a Lollipop device. See the difference here. (The Nexus 10 image is correct but Lollipop does not display correctly) The code is a simple path draw. // Path for the inner circle unitPath = new Path(); unitPath.addArc(unitRect, 180.0f, 180.0f); // Draw the text and the path canvas.drawTextOnPath("Inner Circle", unitPath, 0.0f, 0.0f, unitPaint); canvas.drawPath(unitPath,unitPaint); The Android Studio test project illustrating this issue can be seen here for anyone who wants to see it. https://dl.dropboxusercontent.com/u/6768304/WebLinks/TestApp.rar

Zoom in a canvas using canvas.scale function?

大城市里の小女人 提交于 2019-11-29 04:07:30
I have implemented a long onDraw method which draws a set of rectangles. The rectangles are too small and I want them to appear bigger. But unfortunately I can't change the rectangle coordinates because they are stored in a database. So is there any way I can zoom in the canvas using canvas.scale() ? I'm going to preface this answer by saying you will need to draw everything at 0,0 and then scale it, and finally translate it to behave properly. Simply do the following in your onDraw method: canvas.save(); canvas.translate(xValue, yValue); canvas.scale(xScale, yScale) /* draw whatever you want

Draw a transparent circle onto a filled android canvas

蓝咒 提交于 2019-11-29 02:36:34
I am trying to do something very simple (see above). I want all of the pixels of a canvas to be a solid color, except for the the pixels that fill a centered circle. I have read hundreds stack overflow post on this subject and have tried hundreds of things including setting the PorterDuff.Mode. Here is my current onDraw() of MyView extends View: protected void onDraw(Canvas canvas) { int w = canvas.getWidth(); int h = canvas.getHeight(); Paint framePaint = new Paint(); framePaint.setStyle(Paint.Style.FILL); framePaint.setColor(Color.BLUE); canvas.drawRect(0, 0, w, h, framePaint); Paint

How to add a Marker/Pin on an ImageView Android?

99封情书 提交于 2019-11-29 01:34:21
问题 I would like to ask on how to implement or add a marker on an imageView. I rendered an SVG using svglib and used a customImageView so that I can zoom and pan around the image. here is my code on how i used my customImageView @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { SVG svg; switch (mNum) { case 1: svg = SVGParser.getSVGFromResource(getResources(), R.raw.t1); break; case 2: svg = SVGParser.getSVGFromResource(getResources(), R

Loading large images without OutOfMemoryError

为君一笑 提交于 2019-11-29 01:25:53
I have a 5000 x 4000 px image which I want to draw onto a canvas. First I tried to load it from resources. I put it in /res/drawable . I used the following method: InputStream input = getResources().openRawResource(R.drawable.huge_image); Drawable d = Drawable.createFromStream(input, "image"); d.setBounds(...); d.draw(canvas); It worked like a charm. In this case the InputStream is an AssetManager.AssetInputStream . So now I want to load it from the sdcard. Here's what I tried to do: File f = new File(path); Uri uri = Uri.fromFile(f); InputStream input = mContext.getContentResolver()

Using method -canvas.drawBitmap(bitmap, src, dst, paint)

牧云@^-^@ 提交于 2019-11-29 01:13:43
Everytime I use this code nothing is drawn. I need to draw a bitmap inside of a specified rectangle. canvas.drawBitmap(MyBitmap, null, rectangle, null) I've looked online but can't find much help. triggs EDIT The original answer is incorrect. You can use the sourceRect to specify a part of a Bitmap to draw. It may be null, in which case the whole image will be used. As per the fryer comment he was drawing beneath something, I'll add a note on that. drawBitmap(bitmap, srcRect, destRect, paint) does not handle Z ordering (depth) and the order of calling draw on object matters. If you have 3

Android: How to fill color to the specific part of the Image only? [duplicate]

懵懂的女人 提交于 2019-11-29 00:21:21
This question already has an answer here: how to fill color in image in particular area? 4 answers I have Image Like this: Now, i want to fill the color to the Specific part of that image. as like If i select color blue and if i touch on Cap then the cap should be fill with the color Blue. Same thing should be also happen with the other part like nose, Mouth, Eyes etc So, How it is possible using android ? Can any budy help me please. Updated I have try with the implementation of the FloodFill algorithm in my app. See Here But after doing that i got exception like: 03-09 17:45:16.260: ERROR