android-canvas

Subtractive Filter on Android ImageView (Cut-out a feathered oval from an image or view object)

南楼画角 提交于 2019-12-13 12:48:54
问题 I'm trying to figure out how to "cut-out a feathered hole" in an ImageView. The reasoning is, I am creating a tutorial, and I want the whole screen dim. That's easy enough to do by placing a black image with alpha around 50%. Next I want to cut a hole into that overlay, so you can more clearly see what's underneath it. The goal in mind is to highlight buttons and things for the user to click on, so they learn what to do. When I did this before in ActionScript / Flash, it was easy to just put

Canvas is not Showing Image/Drawable

て烟熏妆下的殇ゞ 提交于 2019-12-13 12:46:37
问题 I am doing a work on SVG Paths and Image. I have loaded SVG file and get an image and try to set thi image on canvas . But canvas is not showing image. I check the height and width and null check of this image/picture and it is not null so i am unable to understand that why canvas is not showing image. any help My code: public class MainActivity extends Activity{ Context c; @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); c=getApplicationContext()

Android: How to draw a two dimensional gradient

我只是一个虾纸丫 提交于 2019-12-13 12:41:16
问题 I am looking to draw a gradient like this using Android's Canvas : In the horizontal direction there is a gradient of two colors (red and blue). Then in the vertical direction there is a gradient of transparency (allowing the red and blue to show) to nothing (the absence of all color?). I found this link on SO here which is close to what I want. But I cannot figure out how to make the bottom transparent. How can this be accomplished in Android? 回答1: Those sort of "custom" gradients can

Find Center of Rectangle [closed]

泄露秘密 提交于 2019-12-13 11:30:47
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . How do you find the center coordinates of a Rectangle drawn in the canvas? The only items I have is the left, right, bottom, and top values. Rect newRect = new Rect(left, top, right, bottom); canvas.drawRect(newRect, paint); 回答1: Just use Rect methods centerX() and centerY() Rect newRect = new Rect(left, top,

How to add button into a Canvas DrawVIew - Android [closed]

有些话、适合烂在心里 提交于 2019-12-13 11:26:36
问题 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 6 years ago . I'm following this tuto the which allow me to draw using the finger: http://marakana.com/tutorials/android/2d-graphics-example.html... I made some changes about drawing and other things... But now i Have to add a

Android canvas drawRect colour always shows as grey?

南笙酒味 提交于 2019-12-13 07:08:29
问题 I'm creating a custom view on Android, but the rendered colour is always grey no matter how I try to change it. private void init() { Resources res = mContext.getResources(); float density = res.getDisplayMetrics().density; mBackgroundWidth = (int)(DEFAULT_WIDTH * density); // default to 20dp mPrimaryColor = gaugeColour; mPrimaryWidth = (int)(DEFAULT_WIDTH * density); // default to 20dp x_Corner=30*density; y_Corner=30*density; mRegularTextSize = (int)(mBackgroundWidth * 0.75); //Double the

How to combine images into single canvas Android

Deadly 提交于 2019-12-13 06:22:28
问题 I have this multiple image in a canvas, how do I get the anchors of each image in the canvas and be able to drag, resize and move it on the canvas. Just like in the other image editor Android applications. Please help me. Thank you here's the code: public class MainActivity extends Activity implements OnClickListener { static final int PICKED_ONE = 0; static final int PICKED_TWO = 1; boolean onePicked = false; boolean twoPicked = false; Button choosePicture1, choosePicture2; ImageView

Drawing a line with canvas from an Activity

佐手、 提交于 2019-12-13 06:08:02
问题 I have read the following links: How to draw a line in android http://marakana.com/s/android_2d_graphics_example,1036/index.html http://developer.android.com/reference/android/graphics/Canvas.html Activity.setContentView, View.setContentView? How to create an activity without 'setContentView(R.layout.main)' http://www.jayway.com/2009/03/26/layout-resources-in-android/ I have read the previous articles that talk about about my problem but I can't solve my problem. My problem is that I want to

Passing x,y coordinates of drawCircle() to drawLine()

瘦欲@ 提交于 2019-12-13 05:47:46
问题 I am trying to draw line between two circles. I have drawn two circles on canvas, These two circles have their cx and cy points. I want to pass these cx and cy of both circles to drawLine()'s startx,starty and stopx,stopy. So that a line should be drawn between these two circles. These two circles can be parallel to each other or horizontal to each other. What I have planned so far is that I should apply action-listener to circles in order to get their x and y coordinates. The problem I am

layered images plus canvas

不打扰是莪最后的温柔 提交于 2019-12-13 05:44:21
问题 I am trying to lay two picture on top of each other. Top one is transparent. On top of them I am trying to add a transparent canvas so the user can draw, type, whatever they need to do and the bottom two images are visible. So I can get the two images to show up or just the canvas. Everytime I try to display the canvas it seems like it is on to[p of the two images covering them. Here is what I have so far.. public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);