android-canvas

Canvas object must be the same instance that was previously returned by lockCanvas

自闭症网瘾萝莉.ら 提交于 2019-12-12 16:25:43
问题 I have a custom SurfaceView with a method doDraw() that draws a background and a bitmap. The problem is when I run this I get an error Caused by: java.lang.IllegalArgumentException: canvas object must be the same instance that was previously returned by lockCanvas I don't see why this is happening. I don't declare any other canvases anywhere else in my code. I only have two other classes, MainActivity and SurfaceViewExample. MainActivity just has an intent to open SurfaceViewExample, and

How to display an image that is bigger than the phone screen dimensions?

。_饼干妹妹 提交于 2019-12-12 09:43:31
问题 I have a question that I didn't find a real consistent answer for. That is why I am reaching out to you guys. I've been trying to achieve a 'viewfinder' effect for my application in the following sense: I have a huge picture that I want to be able to "fly" over (scroll horizontally & vertically until I reach the boundaries). So far, all the popular answers to this (or similar questions) is to use a schema that resembles something like this: <ScrollView...> <RelativeLayout ...> <Imageview ...>

Android - Fill Path with color partially

人走茶凉 提交于 2019-12-12 08:48:38
问题 I am trying to draw a heart shaped Canvas using Path in Android. The code is as follows : @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); // Fill the canvas with background color canvas.drawColor(Color.WHITE); // paint.setShader(null); // Defining of the heart path starts path.moveTo(left + WIDTH / 2, top + HEIGHT / 4); // Starting point // Create a cubic Bezier cubic left path path.cubicTo(left+WIDTH/5,top, left+WIDTH/4,top+4*HEIGHT/5, left+WIDTH/2, top+HEIGHT); //

How to Get a soundcloud like waveforms in Android

杀马特。学长 韩版系。学妹 提交于 2019-12-12 07:14:58
问题 I have generated a simple waveform like the picture below with my code. But I want to give more gap between each line I want it to be like the soundcloud waves like the picutre below. Here is my code: public class VisualizerView extends View { private static final int LINE_WIDTH = 15; // width of visualizer lines private static final int LINE_SCALE = 55; // scales visualizer lines private List<Float> amplitudes; // amplitudes for line lengths private int width; // width of this View private

canvas.drawBitmap bad Location and size (not placing image correctly)

て烟熏妆下的殇ゞ 提交于 2019-12-12 05:48:11
问题 Hi everyone and beforehand thanks, I hope are well write because I am doing a simple application that should unite more than two bitmaps in only one, the problem is in which position bitmaps and size Side wrong, and the truth will not find the back for logic given to me that 's fine, in fact it is a Tengo Que code already in c # and PASE java obviously is different sin but have the same principle . I wonder if you have the way to make the position and size of these images out as this saying

Make a sprite jump

半腔热情 提交于 2019-12-12 04:57:09
问题 I want to make a sprite\bitmap jump using only android (no game engines). I wasn't able to find tutorials on how to do so in android using only canvas and views, but I did find a tutorial for xna(http://www.xnadevelopment.com/tutorials/thewizardjumping/thewizardjumping.shtml), and I tried to recreate it with the tools android offers. I was able to make the character move left and right using the tutorial code but making it jump just won't work. this is my sprite class: package com.example

Teleport the image in the touched position in canvas

醉酒当歌 提交于 2019-12-12 04:47:54
问题 I have tried t create a simple canvas but the image does't appear in the touched position moves only when I drag, I want also that teleports in the touched position if the user clicks a point of the screen My code public class CustomView extends View { Bitmap mBmp; Random mRnd; Paint mPaint; private static final int INVALID_POINTER_ID = -1; private float mPosX; private float mPosY; private float mLastTouchX; private float mLastTouchY; private int mActivePointerId = INVALID_POINTER_ID; private

write text vertically on canvas

我的梦境 提交于 2019-12-12 04:22:34
问题 I want to display text vertically on Canvas . Please help me. 回答1: You want to create a Path object that defines the verticle line you want your text to follow. Then use a canvas.drawTextOnPath() method. 回答2: Refer this url, http://www.pocketmagic.net/?p=1625 , Here they are clearly explained onDraw method , in that method you can use paint and you can set textview with the help of drawText in canvas class, with a sample code sinppet and output. 回答3: Have you tried this: Canvas canvas; canvas

Creating bitmap from canvas java

一个人想着一个人 提交于 2019-12-12 04:05:32
问题 SOLUTION Thanks to @ChandraSekhar's suggestions the issue was that I was passing in an Immutable Bitmap to the canvas constructor. The solution is to create a copy of it when using BitmapFactory.decodeFile(); Bitmap bmp = BitmapFactory.decodeFile(imageURL).copy(Bitmap.Config.ARGB_8888, true); So I have a bitmap that I am using bitmapFactory.decodeFile() for and this works. I am able to create the bitmap, then I need to create a canvas and this is where things get weird. Here's the flow of

Android: Inflate Custom View inside Fragment

浪尽此生 提交于 2019-12-12 03:49:15
问题 I have an application that uses a fragment view as part of its layout. Within this fragment, I want to instantiate a Paint Canvas where i can do custom drawing. The problem is, my app crashes when I go to inflate the fragment with the error android.view.InflateException: Binary XML file line #15: Binary XML file line #15: Error inflating class com.example.xxxxx.NeckCanvasOverlay I'm not sure what's causing my Paint class not to inflate properly. I know there are special rules about how you