android-canvas

How to make EditText Clickable on canvas?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-08 07:54:10
问题 i want to place edit text on tap on canvas. i want to take input from user and set that edit text to canvas. here is my code: @Override protected void onDraw(Canvas canvas) { for (Point point : points) { LinearLayout lL = new LinearLayout(getContext()); EditText editTextView = new EditText(getContext()); editTextView.setFocusableInTouchMode(true); editTextView.setFocusable(false); editTextView.setClickable(true); editTextView.setText("sadsdadadadadsadasds"); editTextView.setVisibility(View

Finding a point after android canvas rotation

痞子三分冷 提交于 2019-12-08 07:46:50
问题 Background info: Using the android canvas and the onDraw() method, I draw a Rect with a small bitmap. Using onTouchEvent() I calculate a rotation on the canvas and do the following. @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.rotate((float)mAngle, mBorderRect.centerX(), mBorderRect.centerY()); canvas.drawBitmap(mCloseBitmap, null, mCloseRect, null); } After the canvas is rotated, the Rect still has the same left, top, right, bottom coordinates. So, when I

Two layers, but can't show the bottom layer in android

落花浮王杯 提交于 2019-12-08 06:23:43
问题 I am working on an Android project similar to a scratch card. I have two layers in RelativeLayout. Bottom layer contains an ImageView, and top layer contains a SurfaceView. The problem is the display stays black and doesn't show the ImageView even if I set canvas.drawColor(Color.TRANSPARENT) . What should I do if I want to scratch and erase the part of SurfaceView and reveal the ImageView below? Thanks in advance. And I am sorry for the bad English. Here's my layout: <?xml version="1.0"

Flood fill algorithm on vector drawable image view

我的梦境 提交于 2019-12-08 06:05:29
问题 I want to create application like this. Flood fill algorithm I applied that code and it is working fine with JPG or PNG file. But I want to use that algorithm with Vector drawable imageview Vector drawable imageview before flood fill After flood fill of vector imageview Expected result should be like this (Flood fill work perfectly when I set JPG or PNG file) @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity

Java Android Canvas.drawText(…) equally big in all screens

那年仲夏 提交于 2019-12-08 05:58:03
问题 I have drawn text with canvas.drawText(...) in my project and tested it against with different devices. However, the size of the text varies a lot from screen to screen. I have tried to multiply it with getResources().getDisplayMetrics().density but they are still slightly not the same size. Is there a way to get the text to have the same size on different devices? 回答1: hi you can look at this post , http://catchthecows.com/?p=72, i think it helps to you. @Override protected void

How to optimize drawing text on canvas

跟風遠走 提交于 2019-12-08 04:09:17
问题 I have window with 3 circles, they are rotating simultaneously. Everything is good until a Add text to the circles, then the rotation starts to lagging. How can i optimize drawing on canvas ? This is my code: @Override protected void onDraw(final Canvas canvas) { if (mPaint == null) { mPaint = new Paint(); mPaint.setTextSize(20f); } drawUpperCircle(canvas); drawBottomCircle(canvas); drawMainCircle(canvas); try { Thread.sleep(1, 1); invalidate(); mRotation += 0.9; } catch (InterruptedException

Draw Path with zoom and darg

江枫思渺然 提交于 2019-12-08 04:06:53
问题 'm developing an application in which I'm pasting images, doing drawing and painting on canvas. This app can also Scale up/down the canvas or drag it to different location. My problem is: I can't get the correct canvas coordinates after scaling or dragging the canvas. I want to draw finger paint after the canvas is scaled or dragged but unable to retrieve the right place where i've touched... @Override public boolean onTouchEvent(MotionEvent event) { scaleListener.onTouchEvent(event);

Java Android Canvas.drawText(…) equally big in all screens

▼魔方 西西 提交于 2019-12-08 04:02:28
I have drawn text with canvas.drawText(...) in my project and tested it against with different devices. However, the size of the text varies a lot from screen to screen. I have tried to multiply it with getResources().getDisplayMetrics().density but they are still slightly not the same size. Is there a way to get the text to have the same size on different devices? hi you can look at this post , http://catchthecows.com/?p=72 , i think it helps to you. @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); // save view size mViewWidth =

how to draw image frame for camera view and overlapping the image frame on captured image

我们两清 提交于 2019-12-08 03:41:52
问题 I am new in android and working on the camera application. In this app I have one transparent image (Image Frame) in assets folder and I want to show this file as my camera view unlike the native camera view. I am getting the camera view screen with the Image Frame using imageview over surface but unable to merge them as output image file on sdcard. Please help thanks in advance... 回答1: Drawable drbl=null; Bitmap topImage = null ; Bitmap b=Bitmap.createBitmap(ref_capturedBitmap.getWidth(),

How tro draw fading path

偶尔善良 提交于 2019-12-08 03:31:00
问题 How can I draw Path with fading (opacity or thicknes) line? Something like this. I know there is LinearGradient shader for Paint , but it won't bend along the Path . One possible solution might be to get points along the Path and just draw it by myself through the segments`. But I coouldn't find any method for that either. 回答1: I came up with the following code. The mos important thing is PathMeasure's getPosTan() method. if (getGesturePath() != null) { final short steps = 150; final byte