android-canvas

RTL support to custom editext for drawable left

限于喜欢 提交于 2019-12-10 21:42:25
问题 I have an edittext having an image as drawable left with a non-editable prefixed editext but now i wanted to make it to support rtl. Despite my effort I am not able to support rtl. My Custom class is as follows, public class PrefixedEditText extends TextInputEditText { private String mPrefix = "+"; // can be hardcoded for demo purposes private Rect mPrefixRect = new Rect(); // actual prefix size public PrefixedEditText(Context context, AttributeSet attrs) { super(context, attrs); } @Override

Andrioid - Unable to re-create Canvas View dynamically

怎甘沉沦 提交于 2019-12-10 19:44:39
问题 I am trying to show a gridview of the canvas images that were drawn in the previous screen. I have a set of different views which is drawn in the first screen and those views are subjected to change, those canvas will be re drawn according to the user's actions. I have 5 heart shaped canvas views and I am using different views for every heart meaning that I am not using a same class to draw the five hearts, rather I am using 5 different class for 5 different hearts. These hearts will be

How to get bitmap of a view? [duplicate]

雨燕双飞 提交于 2019-12-10 19:16:51
问题 This question already has answers here : Convert view to bitmap on Android (5 answers) Closed 2 years ago . Ok, so I'll try my best to explain my problem. I have used this code to get a "screenshot" of my FrameLayout /** * Function that takes a screenshot of the view passed and returns a bitmap for it. * * @param view {@link View} * @return screenshot of the view passed */ public Bitmap screenShot(View view) { Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap

How to scale a square grid to any phone's dimensions

╄→гoц情女王★ 提交于 2019-12-10 19:06:09
问题 Hi I'm trying to make a square 8x8 grid on a canvas. I've managed to make a grid, but it turns out to be rectangular, but for the game I'm making it needs to be square. How do I change my code to make it a square grid scaled to the phone. float testWidth = (getWidth() - 16f) / 9f; float testHeight = (getHeight() - 16f) / 9f; for (int i = 0; i < 9; i++) { canvas.drawLine(padding + testWidth* i, padding, padding + testWidth * i, testHeight* 8+padding, dark); canvas.drawLine(padding, padding

Are Android View transformations applied after rasterization?

只谈情不闲聊 提交于 2019-12-10 17:47:03
问题 The lines (A) and the lines (B) in the code below should produce the same image. Yet lines (A) produce instead the image: What is happening? Are View/Canvas transformations applied after rasterization? import android.content.Context; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Rect; import android.graphics.RectF; import android.view.View; import android.graphics.Matrix; public class MyView extends View { Paint paint = new Paint(); public MyView

UnsupportedOperationException on clipPath

最后都变了- 提交于 2019-12-10 17:18:46
问题 I am getting an UnsupportedOperationException when using Canvas clipPath. This is happening on an HTC Sensation XE (4.0.3). It works perfectly on other 4.0.3 devices. This is the code: @Override protected void dispatchDraw(Canvas canvas) { canvas.save(); canvas.clipPath(this._mClip); super.dispatchDraw(canvas); canvas.restore(); } It fails on the "clipPath" with the following stack: 11-06 12:05:53.650: E/AndroidRuntime(25021): FATAL EXCEPTION: main 11-06 12:05:53.650: E/AndroidRuntime(25021):

how to draw a Bitmap on the Top Right of the Canvas

拜拜、爱过 提交于 2019-12-10 17:12:45
问题 I am trying to draw a bitmap on top right hand corner of the Canvas So far I have done the following: //100x40 dimensions for the bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.backbutton); Rect source = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); Rect bitmapRect = new Rect(0, 0, canvasWidth -200,50); canvas.drawBitmap(bitmap, source, bitmapRect, paint); The problem is that when I run the app, the bitmap doesn't appear on the screen. Full code: public class

How to perform click on circles drawn on a canvas in android?

筅森魡賤 提交于 2019-12-10 17:10:08
问题 I am developing a Face Detection app. In this app, I have to draw circles nearby the eyes and mouth of the face and the user can click to drag circles for setting the position of the same according to him on the detected face. So, all circles have been drawn successfully on the face but I can't able to click on the particular circle and move on throughout the face with zoom out option. Please suggest me for the right solution regarding the same. Thanks in advance. 回答1: Math.sqrt(Math.pow

How to animate the drawing of arc in android

百般思念 提交于 2019-12-10 16:59:46
问题 I am new to Android and I am using the drawArc function to show the progress of some task to the user but now I want to animate this so that it looks as if it is growing. I use the following code but not working: new Thread(new Runnable() { int i=0; float startAngle =0; float swipeAngle = 40.7f; public void run() { while (i < swipeAngle) { canvas.drawArc(rectF, startAngle, i, false, paint); try { Thread.sleep(50); } catch (InterruptedException e) { e.printStackTrace(); } } i++; } }).start();

Canvas drawtext positioning

社会主义新天地 提交于 2019-12-10 15:53:39
问题 I am creating a drawing tool, where user add text to image. While making the text draw to bitmap via canvas position is not being set properly. Paint paint = new Paint(); paint.setStyle(Paint.Style.FILL); paint.setColor(Color.RED); paint.setTypeface(tf); paint.setTextAlign(Paint.Align.LEFT); paint.setTextSize(30); int xPos = layoutTextViewContainer.getLeft(); int yPos = layoutTextViewContainer.getTop(); canvas.drawText(text, xPos, yPos, paint); Paint Rect textRect = new Rect(); paint