ondraw

Drawing to a created Bitmap from onDraw()

怎甘沉沦 提交于 2019-12-11 06:22:00
问题 I'm trying to draw to a Bitmap so I can put my custom view inside an imageView.The code within the onDraw method is: public void onDraw(Canvas canvas) { Bitmap drawGraph = Bitmap.createBitmap(canvas.getWidth(),canvas.getHeight(),Bitmap.Config.ARGB_8888); canvas.setBitmap(drawGraph); canvas.drawBitmap(drawGraph, 0, 0, bgPaint); My problem is that if I try to use a Bitmap in this way, I just get a black screen. I know that the rest of my code works as it displays if I don't try to draw to a

Drawing multiple lines on canvas with delay in between

a 夏天 提交于 2019-12-11 05:10:40
问题 after few months i finally managed to create my first non trivial app. Now I want to add some nice animation (not sure it is a proper term), like step-by-step drawing my graph. Gif below explains what I need. At this point my app draw the graph at once, without any delaying. In MyFragment class there is FrameLayout where custom View (my graph) is added: public class MyFragment extends Fragment{ ... FrameLayout mFL; MyDraw mydraw = new MyDraw(getContext(),floatArray_coord_X,floatArray_coord_Y)

Paint.getTextBounds() returns to big height

百般思念 提交于 2019-12-11 03:37:41
问题 EDIT: The problem came from the emulator, the error did not appear on a real device :( I'm trying to draw some text in a custom view and must there for measure it but the value of the Paint.getTextBounds() returns a height which is about 30% higher then the actual text which gives everything a quirky look. I found this: Android Paint: .measureText() vs .getTextBounds() and tried to add the solution code to my own onDraw and saw that i the same measuring error as in my code. Here is a picture

Saving Canvas in onDraw();

≡放荡痞女 提交于 2019-12-10 23:36:37
问题 I'm trying to save the Canvas object in a onDraw() method. This is because i'm using a foreach loop in the onDraw method resulting in : canvas.DrawText (textitem , x,y, textpaint); (i have to do this because im drawing the text around a masked area) what im trying now is this : @Override public void onDraw(Canvas canvas) { if (hasrun = false) { for(CustomTextViewDrawItem item : drawItemList) { canvas.drawText(item.Text, item.X, item.Y, textPaint); } if (eLabel.backgroundGradient != null) {

Opengl-es onTouchEvents problem or a draw problem? [closed]

梦想与她 提交于 2019-12-10 23:03:06
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 8 years ago . I am just getting started with using opengl in my apps and I get it fine =) but I've hit a brick wall recently as I have been attempting to work out methods of user input. I decided to start with a simple process

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 set canvas size?

北城余情 提交于 2019-12-10 13:03:31
问题 I have a class named SeatsPanel where I draw seats (using drawRect) in the onDraw method. The onDraw method uses Canvas as a parameter, but how do you set size of the Canvas? The reason why I'm asking this question is because this class is being inflated in another class. I know that the canvas has the default height and width of the phone, but I need to make it smaller. How can I do this? Any help would be appreciated. -Tolga- 回答1: I've tried to implement a simple application that draws a

Drawing on Canvas outside the onDraw() method

老子叫甜甜 提交于 2019-12-10 09:24:34
问题 Here's my OnDraw() method void onDraw(Canvas canvas) { mCanvas = canvas; //invalidate(); int x = 0; Iterator<Letter> it = mNextUpQueue.iterator(); while(it.hasNext()){ mCanvas.drawBitmap(it.next().getNext(), mNextUpCoordinates.get(x).x, mNextUpCoordinates.get(x).y, mPaint); mCanvas.drawBitmap(mAvailableLetters.get(x).getNotPressed(), mAvailableLettersCoordinates.get(x).x, mAvailableLettersCoordinates.get(x).y, mPaint); x++; } } I have set canvas to a global variable mCanvas. But if I try to

android--------自定义控件 之 方法篇

痴心易碎 提交于 2019-12-10 07:41:02
前面简单的讲述了Android中自定义控件的理论和流程图,今天通过代码来详细的讲解一下其中的方法 首先先创建一个类 CircularView 继承于 View,之后实现构造方法(初始化步骤) public class CircularView extends View { public CircularView(Context context) { super(context); } public CircularView(Context context, AttributeSet attrs) { super(context, attrs); } public CircularView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public CircularView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } } View的构造函数有四种重载,View构造函数的参数有多有少, 有四个参数的构造函数在API21的时候才添加上

Android: Drawing an arc inside a circle

本秂侑毒 提交于 2019-12-09 12:53:58
问题 I'm trying to draw an arc inside a circle to represent the temperature, but I'm having a difficult time achieving that. During my search I found those solutions This one I couldn't understand what is the scale method for, and is drawing more than one arch, which confused me a bit This post gave it a fixed size where I need the size to be controlled by the custom view in my XML layout From here I understood the concept the degrees but I didn't understand how to determine the oval size What i