android-canvas

Use hardwareAcceleration flag with Canvas.clipPath

寵の児 提交于 2019-12-23 20:32:57
问题 I'm porting a project made for the Galaxy Tab 1, for Galaxy Tab 2, but the apk runs slowly so I added the hardwareAccelerated flag on the AndroidManifest.XML of the new application. But running give me the following error: java.lang.UnsupportedOperationException at android.view.GLES20Canvas.clipPath(GLES20Canvas.java:287) at br.com.iba.view.PageCurlView.drawCurl(PageCurlView.java:284) at br.com.iba.view.PageCurlView.onDraw(PageCurlView.java:353) at android.view.View.draw(View.java:9291) 回答1:

Creating transparent circle cutout in a View in Android

半城伤御伤魂 提交于 2019-12-23 18:22:59
问题 I'm trying to create a translucent help overlay to be displayed over my activity's main screen when the user first opens the app. I would like to highlight a button contained in the main layout (and inflated using setContentView), by "cutting out" a section of the overlay which corresponds to the position of the button, and make the cutout transparent. The overlay is a programmatically-created view (which extends RelativeLayout) which is added to my activity's main FrameLayout, like this:

drawCircle vs drawBitmap

醉酒当歌 提交于 2019-12-23 17:51:04
问题 I'm planning on implementing a new set of figures in my game: plain circles. The number of drawn sprites (in this case circles) starts with 2-3, and can go up endlessly (potentially). The maximum will probably be around 60 though. In total there will have to be 5 types of circles, each with a different color and probably size too. Now seeing as I won't implement it until monday I thought I'd ask it at stackoverflow. Does anybody already know which method is faster? 回答1: Bitmaps are almost

drawCircle vs drawBitmap

做~自己de王妃 提交于 2019-12-23 17:43:18
问题 I'm planning on implementing a new set of figures in my game: plain circles. The number of drawn sprites (in this case circles) starts with 2-3, and can go up endlessly (potentially). The maximum will probably be around 60 though. In total there will have to be 5 types of circles, each with a different color and probably size too. Now seeing as I won't implement it until monday I thought I'd ask it at stackoverflow. Does anybody already know which method is faster? 回答1: Bitmaps are almost

Eraser is not called when button is pressed

我怕爱的太早我们不能终老 提交于 2019-12-23 12:59:44
问题 I have main class like this: public class Main extends Activity { Button edit,save,eraser,clear; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); edit = (Button) findViewById(R.id.edit); save = (Button) findViewById(R.id.save); clear = (Button) findViewById(R.id.clear); eraser = (Button) findViewById(R.id.eraser); eraser.setOnClickListener(new OnClickListener() {

Fill pattern in Image in Android

牧云@^-^@ 提交于 2019-12-23 10:18:16
问题 Two images are given blow i call first image as frame image and second image as frame image.Here fst is my Linear Layout and i set the frame-image as background image of it. Now i want to fill the pattern image in my frame image's white area. Outer area of the frame image is transparent and inner area is white. How can i fill pattern image in my frame-Image. I tryied this code. private void patternFill(Bitmap tempBitmapColor) { Bitmap bmp = BitmapFactory.decodeResource(getResources(), R

Trying to create an Eraser Paint for canvas

自古美人都是妖i 提交于 2019-12-23 07:48:51
问题 I am creating a drawing app that utilizes the DrawingSurfaceView class below. In that class i have a Paint Called eraserPaint that the user can toggle on and off.. When on that paint is suppose to eraser what ever is in its path. but instead its just drawing a black line.. When i save out the canvas as a transparent png the eraser is correct but on the screen it shows black.. Screenshot from phone of EraserPaint used to write "Erik" on blob Saved out PNG from canvas eraserPaint looks like

Android drawCircle with different colour border

送分小仙女□ 提交于 2019-12-23 07:08:52
问题 Is it possible to draw a circle on a canvas in Android with a different colour border using only one drawCircle method? I have noticed the PaintStyle of FILL_AND_STROKE but cant seem to have different colours for both the fill and the border. I really don't want to have to call two drawCircle methods. 回答1: Definition of Paint.Style says: Paint.Style The Style specifies if the primitive being drawn is filled, stroked, or both (in the same color). So it seems it can't be done in one go. If you

Draw canvas on Rect with image and text

本小妞迷上赌 提交于 2019-12-23 06:09:17
问题 I've trying to create a button using Rect . I've created this successfully but my image and text is not properly on center. I want set in exact center but can't achieve. I need to do this by Rect . please guide me, any help would be appreciated. Thanks Here is my code snippet RectF rightButton = new RectF(itemView.getRight() - buttonWidthWithoutPadding, itemView.getTop(), itemView.getRight(), itemView.getBottom()); p.setColor(Color.parseColor("#F44336")); c.drawRoundRect(rightButton, corners,

canvas.drawText with pixel perfect text on a canvas

半腔热情 提交于 2019-12-23 05:36:09
问题 THIS IS NOT ABOUT AntiAlias, Please read the question before answering thank you. ADDING BOUNTY TO--> android convert text width (in pixels) to percent of screen width/height Quality info --> https://stackoverflow.com/a/1016941/1815624 I am getting inconsistent results when trying to draw text on a canvas. Please help, thank you. I want the text to consume the same amount of scaled space on all devices I do not care about ANTI_ALIAS and have added the paint.setFlags(Paint.ANTI_ALIAS_FLAG);