ondraw

Override DrawItem of ComboBox

末鹿安然 提交于 2019-12-02 12:14:19
I changed the highlight color of various of the controls, and I am planning to make more changes. So I though is better to create my own controls and reuse them instead of making the changed for each and every one of them. I created a new user control, and inherited from System.Windows.Forms.ComboBox . The problem is I cannot find a way to override onDraw like I would for onClick . So how I would go and override it? Here is the code I used for each control onDraw event public void comboMasterUsers_DrawItem(object sender, DrawItemEventArgs e) { e.DrawBackground(); Graphics g = e.Graphics; Brush

Android canvas - Draw a hole

随声附和 提交于 2019-12-01 06:16:40
Is it possible to realize the following picture in Android with canvas? I want to have a hole and not only a Circle over the red layer which is yellow colored. I tried this (and failed) with the following Code in my onDraw() -Method: canvas.drawBitmap(yellow, 0, 0, paint); canvas.drawBitmap(red, 0, 200, paint); Paint p = new Paint(); p.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); canvas.drawCircle(300, 300, radius, p); But when I use this code, it makes a hole through both bitmap's. At the end, this App should be a Maze with a ball, holes and other stuff. When the ball would

Android: How to use the onDraw method in a class extending Activity?

淺唱寂寞╮ 提交于 2019-12-01 05:07:10
As a beginner, I've been building a simple counter application using a simple layout xml and a class called 'Counter', which derives (extends) from the class Activity. Now, I want to load a bitmap (png file) to place next to the counter. I've been reading up on onDraw(), but it requires the class to extend 'View'. I've been trying to create an object of this class to use this instead, to no avail. I'm a bit stumped about this concept, how to do it easily. If anyone could explain, I'd appreciate it. Simple example using onDraw function-it requires class to extend view Context to get the current

Android: How to use the onDraw method in a class extending Activity?

谁都会走 提交于 2019-12-01 02:13:19
问题 As a beginner, I've been building a simple counter application using a simple layout xml and a class called 'Counter', which derives (extends) from the class Activity. Now, I want to load a bitmap (png file) to place next to the counter. I've been reading up on onDraw(), but it requires the class to extend 'View'. I've been trying to create an object of this class to use this instead, to no avail. I'm a bit stumped about this concept, how to do it easily. If anyone could explain, I'd

How do I make my animation smoother Android

泄露秘密 提交于 2019-11-30 15:37:10
I have an app that has a ball running across the screen. When the ball is halfway the application records some audio, computes the FFT and does some extra analysis. This is handled by Asynctask, however the animation still briefly stutters. Does anyone have any suggestions on how to make it run smoother? Thanks code below: import com.ben.applicationLayer.GameView; import dataObjectLayer.Sprite; import dataObjectLayer.MusicalNote; import android.media.AudioRecord; import android.media.MediaRecorder.AudioSource; import android.media.AudioFormat; import android.os.AsyncTask; public class

Android draw using SurfaceView and Thread

跟風遠走 提交于 2019-11-30 08:21:26
问题 I am trying to draw a ball to my screen using 3 classes. I have read a little about this and I found a code snippet that works using the 3 classes on one page, Playing with graphics in Android I altered the code so that I have a ball that is moving and shifts direction when hitting the wall like the picture below (this is using the code in the link) . Now I like to separate the classes into 3 different pages for not making everything so crowded, everything is set up the same way. Here are the

View.onDraw() — when does it get called?

随声附和 提交于 2019-11-30 04:27:51
I put a Log.d() call into the onDraw() of my extended View, so I could see how often and when it's getting called. It gets called upon instantiation of the view, which is not surprising. But then I notice, it gets called on every tap that is handled by onTouchEvent(), even though my code there isn't doing anything remotely related to graphics. However, in the documentation for Views, I can't seem to find anything about when onDraw() is actually called. I'm not really concerned about my particular project here (this doesn't cause a problem for me), I would just like to know if there is a list

How do I make my animation smoother Android

会有一股神秘感。 提交于 2019-11-29 22:07:31
问题 I have an app that has a ball running across the screen. When the ball is halfway the application records some audio, computes the FFT and does some extra analysis. This is handled by Asynctask, however the animation still briefly stutters. Does anyone have any suggestions on how to make it run smoother? Thanks code below: import com.ben.applicationLayer.GameView; import dataObjectLayer.Sprite; import dataObjectLayer.MusicalNote; import android.media.AudioRecord; import android.media

android, how to draw dotted line in edittext

青春壹個敷衍的年華 提交于 2019-11-29 14:58:39
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 = new DashPathEffect(new float[]{5,5,5,5},1); mPaint.setPathEffect(effects); } @Override public void

Android draw using SurfaceView and Thread

假装没事ソ 提交于 2019-11-29 06:35:38
I am trying to draw a ball to my screen using 3 classes. I have read a little about this and I found a code snippet that works using the 3 classes on one page, Playing with graphics in Android I altered the code so that I have a ball that is moving and shifts direction when hitting the wall like the picture below (this is using the code in the link) . Now I like to separate the classes into 3 different pages for not making everything so crowded, everything is set up the same way. Here are the 3 classes I have. BallActivity.java Ball.java BallThread.java package com.brick.breaker; import