android-canvas

Adding a colored background with text/icon under swiped row when using Android's RecyclerView

百般思念 提交于 2019-11-27 17:24:29
EDIT: The real problem was that my LinearLayout was wrapped in another layout, which caused the incorrect behavior. The accepted answer by Sanvywell has a better, more complete example of how to draw a color under swiped view than the code snippet I provided in the question. Now that RecyclerView widget has native support for row swiping with the help of ItemTouchHelper class, I'm attempting to use it in an app where rows will behave similarly to Google's Inbox app. That is, swiping to the left side performs one action and swiping to the right does another. Implementing the actions themselves

Draw a transparent circle onto a filled android canvas

好久不见. 提交于 2019-11-27 16:57:11
问题 I am trying to do something very simple (see above). I want all of the pixels of a canvas to be a solid color, except for the the pixels that fill a centered circle. I have read hundreds stack overflow post on this subject and have tried hundreds of things including setting the PorterDuff.Mode. Here is my current onDraw() of MyView extends View: protected void onDraw(Canvas canvas) { int w = canvas.getWidth(); int h = canvas.getHeight(); Paint framePaint = new Paint(); framePaint.setStyle

How to add rectangles on top of existing rectangle in canvas

*爱你&永不变心* 提交于 2019-11-27 16:05:43
I'm trying to add some red rectangles within my existing canvas on top of specific boxes exactly like the expected result image but they don't appear at all as my code shows the current undesired outcome when I deploy my app. My code is to create 4 rectangles on the top row and 4 rectangles on the bottom row but I only want this to be added on top of boxes 2-6 but I know extra code needs to be added for the red rectangles on top of boxes 1 & 7. Does anyone know what I'm doing wrong and how to fix this? All help would be appreciated. public class RectangleTextView extends View { private final

Change color without affecting anything previously drawn

时光总嘲笑我的痴心妄想 提交于 2019-11-27 15:51:41
I have the following CustomView I am using for painting in my app: package com.test.testing; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Path; import android.graphics.Paint.Style; import android.view.MotionEvent; import android.widget.TextView; public class CustomView extends TextView { Paint paint; Path path; float x = 0; float y = 0; private int cWhite = Color.WHITE; public CustomView(Context context) { super(context); paint = new Paint(); path= new Path(); paint.setAlpha(255); paint

Using method -canvas.drawBitmap(bitmap, src, dst, paint)

空扰寡人 提交于 2019-11-27 15:42:24
问题 Everytime I use this code nothing is drawn. I need to draw a bitmap inside of a specified rectangle. canvas.drawBitmap(MyBitmap, null, rectangle, null) I've looked online but can't find much help. 回答1: EDIT The original answer is incorrect. You can use the sourceRect to specify a part of a Bitmap to draw. It may be null, in which case the whole image will be used. As per the fryer comment he was drawing beneath something, I'll add a note on that. drawBitmap(bitmap, srcRect, destRect, paint)

Android: How to fill color to the specific part of the Image only? [duplicate]

不想你离开。 提交于 2019-11-27 15:15:55
问题 This question already has answers here : how to fill color in image in particular area? (4 answers) Closed 2 years ago . I have Image Like this: Now, i want to fill the color to the Specific part of that image. as like If i select color blue and if i touch on Cap then the cap should be fill with the color Blue. Same thing should be also happen with the other part like nose, Mouth, Eyes etc So, How it is possible using android ? Can any budy help me please. Updated I have try with the

Is it possible to display multi-color text with one call to Canvas.drawText()?

依然范特西╮ 提交于 2019-11-27 15:06:46
问题 I would like to use Canvas.drawText() to display multi-color text. More specifically, I want to highlight a substring of the text passed to the drawText() method. The text is in the form of a SpannableString with 0 or more ForegroundColorSpan objects. Looking at the Canvas code, it appears that a .toString() call on the passed CharSequence, means that this is not possible. Is there an alternative way? EDIT: The text may occasionally change (total changes, not incremental). Also, there are

Android: Drawing a canvas to an ImageView

拟墨画扇 提交于 2019-11-27 12:39:09
I'm new to android programming and what I'm trying to figure out is this; In my layout i have a TextView, ImageView, and Button, all on a vertically oriented LinearLayout. I want to be able to dynamically draw circles in the ImageView, without disturbing the rest of my layout(textview/button). I'm trying to create a canvas, and use the drawcircle function within canvas to set the location of the circle. And then draw that canvas to my imageview in some way. I cannot get this to work, is there a trick to this? Or is my method fundamentally wrong? How would i go about drawing circles to the

Android: How to do this framing paint?

百般思念 提交于 2019-11-27 12:31:36
I Have Some static images like below: Now, I want is, when i touch on the face or hand, then the selected color should be fill on that skin portion. See below image of result: So how to get the result like above ?? Redo and Undo Functionality Should be also there. I have try with the FloodFill color but doing that i can only able to do color in to the perticular portion. as FloodFill only fill the color till the same pixwl color comes. If the touch place pixel color get change the it will not fill color on it. So Usinf FloodFill i got the result like below image, If i press on the hand, then

Android Live Wallpapers — OpenGL vs Canvas

筅森魡賤 提交于 2019-11-27 12:25:31
问题 I am a fairly "newb" Android developer, and I would like one of my first projects to be a live wallpaper, however I am conflicted on whether I should be focusing on Canvas or OpenGL for it. Being new to this I know I should master Canvas first since it is easier to use, but I prefer to learn from real world projects that I have an interest in, even if it's a little backwards at times. I have used both before in very basic ways, and I understand the general concepts to them, but I am not sure