android-canvas

is canvas in android proportional on different devices

孤者浪人 提交于 2019-11-29 16:40:25
I am trying to make an app using canvas and a surfaceview, and I am worrying that in the future I would have many problems with it because I am not sure if the canvas is proportional with every device. currently I can only use my emulator since my phone's usb cable doesn't work(I know.. I have to get a new one..). anyways, i would like to know if the canvas would transfer my coordinates and make everything proportional, what I mean by that is that if i have something in point a, lets say (10, 10) on a device that the screen of it is 100 X 100 (this is just an example for easy calculation) it

Plot Multiple Charts in one in MPAndroidChart

与世无争的帅哥 提交于 2019-11-29 14:09:08
I have to plot two different dataSets in a single graph. DataSet-1 String[] xAxisOne = new String[] { "0", "1", "2", "3", "4", "5", "6" }; float[] dataInput = { 1f, 2f, 3f, 4f, 5f, 6f, 7f }; DataSet-2 String[] xAxisTwo = new String[] { "0", "2", "4", "5", "6", "8", "9" }; float[] dataIn = { 3f, 4f, 5f, 6f, 7f, 8f, 9f }; In the above data, DataSet-1 is reference by which graph is created. DataSet-2 has to be plotted in the same with different set of X-Values {xAxisTwo} . In existing Implementation, first 6 values {dataInput} are plotted & next 6 values {dataIn} are plotted with reference to

Android Drawing bitmap and button on canvas by X Y Positions

落花浮王杯 提交于 2019-11-29 12:51:47
i'm new into android and i have some problems with my app. Any help will be appreciated :) I have drawing bitmap on canvas by xpositon and ypostion by sensors (when i'm moving my phone, bitmaps are moving ) I need to create moving clickable button on center of my bitmaps and when i click them i will go to next activity . Bitmaps are drawing perfectly but idont know how to draw buttons on them, buttons that will be moving with my bitmap by the same values of x and y. How i can do that? This is my piece of code: private void updateBall() { // Calculate new speed // xVelocity += (xAcceleration *

Android: Adding Background on a Custom TextView class

喜你入骨 提交于 2019-11-29 12:02:28
I want to have a background of my TextView class, but I don't know how. I try to use the onDraw method on the class but it is not working. Here is my code for my custom TextView class. public class Balls extends TextView{ public Balls(Context context) { super(context); // TODO Auto-generated constructor stub this.setText("ball"); } protected void onDraw(Canvas canvas) { super.onDraw(canvas); Paint paint = new Paint(); paint.setColor(Color.RED); canvas.drawCircle(50, 50,30, paint); }} Any idea how can I fix this code? Thanks. Anil Jadhav You can set Background in following way, public class

How to get current canvas?

倾然丶 夕夏残阳落幕 提交于 2019-11-29 11:58:02
问题 I have DrawView. If I touch this view it draws small circles. I wont to draw circles but not to touch view - with help function "setPoints". What I do: package com.samples; import ... public class DrawView extends View { ArrayList<Point> points = new ArrayList<Point>(); Paint paint = new Paint(); private int pSize = 5; private int pColor = Color.BLACK; public DrawView(Context context, AttributeSet attrs) { super(context, attrs); setFocusable(true); setFocusableInTouchMode(true); this

SurfaceView shows black screen - Android

会有一股神秘感。 提交于 2019-11-29 10:08:06
Basically I want to use SurfaceView for animation. Therefore the class implements Runnable. To experiment, I want to draw a circle. However, it shows only a black screen. I have been trying for days. Really appreciate if someone can help. MainActivity class public class MainActivity extends Activity { private Bitmap Liquid; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature (Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); DrawStripFrame D1

How to show both MarkerIcon and Title in google map as like Google Apps?

耗尽温柔 提交于 2019-11-29 10:02:10
When I find nearest restaurants in Google's Maps Android Application the restaurant name is showing near to marker icon as default. (Refer Google Image). But in my application I need to do same when I search for nearest restaurants, I able to display only marker icons. (Refer My Application Image). Google Image: My Application Image: Partial Solution : Here I found partial solution for this we get this by drawing a text using canvas. I used below code refer by these links here and here But canvas drawing cutting of my text. Refer attached image TextDrawn Image Marker myLocMarker = map

Draw a circle on an existing image

浪子不回头ぞ 提交于 2019-11-29 09:35:31
问题 I'm trying to draw a circle on an image which placed as res/drawable/schoolboard.png . the image fills the activity background. the following does not work: Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.schoolboard); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(Color.BLUE); Canvas canvas = new Canvas(bitmap); canvas.drawCircle(60, 50, 25, paint); ImageView imageView = (ImageView)findViewById(R.drawable.schoolboard); imageView

How to set ontouch listener for something drawn using canvas: Android

孤街浪徒 提交于 2019-11-29 09:22:56
问题 I have a custom view in which i am drawing one big circle and a small circle on the edge of this big circle. I would like to move the small circle and so would like to have a ontouch listener only for the small circle. Could some please tell me how to set the ontouch listener for only the small circle. public class ThermoView extends View{ private ImageView mThermostatBgrd; private ImageView mCurTempArrow; private ImageView mSetPointIndicator; public static final int THEMROSTAT_BACKGROUND = 0

Capture image using dynamic co-ordinates through the camera

喜你入骨 提交于 2019-11-29 08:19:27
I am making a camera based application, where I put a rectangular view over the camera. When I capture an image using new Camera.PictureCallback() , I cropped that image so as it will get the part of the rectangle. Well, its working fine. Now I implemented View.OnTouchListener and using that I made the shape movable. So, I need to capture the image with the final selection of the user, like where they place the rectangle. Bitmap imageOriginal = BitmapFactory.decodeByteArray(data, 0, data.length); // 2560×1440 float scale = 1280 / 1000; int left = (int) (scale * (imageOriginal.getWidth() - 250)