ondraw

onDraw fill shape create with canvas.drawLine

十年热恋 提交于 2019-12-04 17:11:53
i draw 4 lines (canvas.drawLine) in order to draw a rectangle. Is there any possibility to fill the area of the rectangle? (I know that android have a rectDraw. Mine is only curiosity) thanks in advance. ok.. I ve also a path created a path segment. Following the code.. Please can u explain how fill the internal area? `Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setStrokeWidth(2); paint.setColor(android.graphics.Color.RED); paint.setStyle(Paint.Style.FILL_AND_STROKE); paint.setAntiAlias(true); path.reset(); path.setFillType(Path.FillType.INVERSE_EVEN_ODD); path.moveTo(mPin[0].getX()

Draw From Old Canvas - Android

这一生的挚爱 提交于 2019-12-04 16:01:17
问题 I'm making an App that needs to be able to draw new graphics on top of the last set. This is my current onDraw() method - protected void onDraw(Canvas canvas) { canvas.drawColor(Color.WHITE); if(points.size() > 0) { //do some stuff here - this is all working ok canvas.drawLine(p1.x, p1.y, p2.x, p2.y, linePaint); } } Basically, I need to draw the new graphics as a layer on top of the last, so what I'm looking for is a way to carry the image of the last canvas to the current. I have tried to

subclassing SurfaceView and overriding onDraw() to change SurfaceView parameters to generate preview of desired size

蹲街弑〆低调 提交于 2019-12-04 14:35:14
I have subclassed the SurfaceView and instantiating it in onCreate of the Activity. The preview is generated but the control never enters onDraw() which is overriden in the subclass of SurfaceView. Why is that? class ActivityClass extends Activity{ onCreate(){ mPreview = new Preview(this); setContentView(mPreview); } public void startPreview(){ rec = new MediaRecorder(); rec.setVideoSource();....... rec.setPreviewDisplay(mPreview.getSurfaceHolder.getSurface()); } } class Preview extends SurfaceView implements SurfaceHolder.Callback{ SurfaceHolder mHolder; public Preview(Context context){ super

Custom Knob View for controlling Volume?

让人想犯罪 __ 提交于 2019-12-04 10:59:04
I want to show progress bar around knob. After following this tutorial I created this knob it is working fine. But How could i modify the above knob to look like the second image Running code for the first knob is written below. import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.RectF; import android.view.GestureDetector; import android.view.GestureDetector.OnGestureListener; import android.view

Draw a text on a circle path in android

大兔子大兔子 提交于 2019-12-04 08:37:16
I need to draw a text on a circle path. I have tried the drawTextOnPath() method. But for texts like "fertile window" in the image attched, the text rotates and is not readable. Code I have used : customPath2.addArc(mCircleRectF, 30F, 64.28F); customPaint2.setAntiAlias(true); customPaint2.setDither(true); customPaint2.setStrokeWidth(mCircleStrokeWidth); customPaint2.setColor(Color.parseColor("#93BE66")); customPaint2.setStyle(Paint.Style.STROKE); customPaint2.setStrokeCap(Paint.Cap.ROUND); canvas.drawPath(customPath2, customPaint2); titlePaint.setColor(Color.parseColor("#ffffff")); titlePaint

How to define a pixel independent height in an onDraw() method

二次信任 提交于 2019-12-04 06:16:02
I have extended View to build a custom widget. I would like to define the height of the widget with an independ pixel unit. I think it could be done by multiplying the pixel density by the desired height , but i don't know how to do that. What i have so far (minimized) : public class Timeline extends View { @Override protected void onDraw(Canvas canvas) { //super.onDraw(canvas); int canvasWidth = canvas.getWidth(); this.widgetWith = canvasWidth; this.setBackgroundGradientNoVideo(); RectF rect = new RectF(); rect.set(0, 0, canvasWidth, 50); //Dessin d'un rectangle de fond canvas.drawRoundRect

Android How to create onClick events in Canvas onDraw method

拜拜、爱过 提交于 2019-12-04 05:16:21
问题 i've searched around and still can't find a good answer. I have made my own class that extends an imageView and in the onDraw() method i am using canvas to draw circles onto my image. What i want to do now though is draw a button onto the image in different places and have an onClick event for it, so when the user presses the button it will open up a new activity.. Here is what I have so far..It draws the buttons in the right locations except my onClick method isn't firing @Override protected

Draw overlay (HUD) on Android VideoView?

◇◆丶佛笑我妖孽 提交于 2019-12-04 04:04:57
I have a custom view that draws HUD : Here is my layout: <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <VideoView android:id="@+id/videoView1" android:layout_gravity="center" android:layout_width="match_parent" android:layout_height="wrap_content" /> <com.widgets.HUD android:id="@+id/hud" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </FrameLayout> public View onCreateView(LayoutInflater inflater,

android, how to draw dotted line in edittext

廉价感情. 提交于 2019-12-03 18:14:12
问题 I refered to this link: How do I make a dotted/dashed line in Android?, and used DashPathEffect . But this does not work for me? why? my code: public class NoteEditText extends EditText { private Paint mPaint; public NoteEditText(Context context) { super(context); } public NoteEditText(Context context, AttributeSet attrs) { super(context, attrs); mPaint = new Paint(); mPaint.setStrokeWidth(1); mPaint.setStyle(Paint.Style.FILL_AND_STROKE); mPaint.setColor(Color.DKGRAY); PathEffect effects =

Android: Drawing an arc inside a circle

泄露秘密 提交于 2019-12-03 15:52:37
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 reached so far @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); int startTop = 0;