Android :: Simplest Way To Draw Pixels Lines / Circles On A View?
Aug 14, 2010
What is the simplest way to draw pixels, lines and circles on a View?I want to move a cross cursor around, so nothing particularly intensive.I thought I could extend SurfaceView and add it to an XML and it would just work, but it just appears black, however, when I look at the layout view of localmap.xml in eclipse, the graphics appear as expected. Any ideas? My onDraw is never called on the emulator, and even calling invalidate on the class makes no difference. I shall keep trying but can anyone see anything I've missed? or is there a better way entirely? Code...
View 1 Replies
Feb 24, 2010
I' trying to complete an assignment. I need to be able to draw circles with the canvas in Android and also draw the ten previous circles while my finger moves. I have saved the coordinates in an arraylist and tried to use a for loop to draw all of the circles. Here is my code, I'm just looking for suggestions not answers if anyone has any. I will attach my code. Right now it only draws one circle at a time.
`package edu.elon.cs.mobile;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Paint.Style;............
View 1 Replies
View Related
Jun 15, 2010
I am trying to draw a cupola circles at random positions in an Android application. I draw them on a bitmap and then draw that bitmap on the canvas. This is the function where a draw the circles:
private void drawRandomCircles(int numOfCircles) {
Canvas c = new Canvas(b);
Paint cPaint = new Paint;
cPaitn.setColor(Color.RED);
for(int i = 0; i < numOfCircles; i++) {
int x = Math.Random % 100;
int y = Math.Random % 100;
c.drawCircle(x, y, 20, cPaint)
}
}
The Bitmap b is global. And after calling this function I just draw the bitmap in the onDraw method. Now the problem is that I only get one circle drawn on the screen, no matter the size of numOfCircles.
View 1 Replies
View Related
Apr 28, 2010
How to draw different types of lines like thick line, dashed line etc using opengl android?
View 6 Replies
View Related
May 7, 2010
i have a customized LinkedEditText extends from EditText, and override the onDraw method as below:...........................
View 9 Replies
View Related
Dec 29, 2009
what is best way to create app in which I only need to draw simple lines through onTouchEvent? When i use invalidate everytime i draw any line, that erase lines i draw before. But if I use some List structure to store drawed lines it lose performance. Is there any simple way to do it?
View 6 Replies
View Related
Jul 23, 2010
I am working on a paint application for Android. Now I want to implement an eraser to allow erasing parts of a loaded bitmap by using touch input and making the bitmap transparent along the finger's path.
A very good example of what I try to achieve is shown in the application Steamy Window for Android. Steamy Window simulates a fogged window, where a user can wipe parts of the fog via touch input.
UPDATE: I have posted the most important sections of my current code below. I am not really happy with it for the following reasons:
Drawing is quite sluggish. What can I improve here?
I am looking for a way to use an alpha mask in order to set the pixel transparency/alpha of the pixels as I want to simulate a paint brush. Any suggestions how this could be achieved?
CODE:...................
View 1 Replies
View Related
Nov 11, 2010
I'm writing an app that shows in google maps pipes and valves(lines and points). For that i've two classes.
One extends from ItemizedOverlay, and i add to map overlay one for each category of valve, and each one can have more than one item.
The second extends from Overlay, and in the draw method y draw the line with the method drawline of the canvas.
The problem i've is that the lines are drawn over the ItemizedOverlay items, no matter the order i add them to the mapView.getOverlays().
I want the lines on the bottom of all overlays. is there a way to do that.
View 1 Replies
View Related
Nov 20, 2010
I tried enough to find in google & android this question. Also did several trials & errors, but couldn't get this question. was learning Android's "Draw Nine Patch" images. One basic I know is that, whatever image you process must be in .png format (if it's already in .9.png then it will be ignored by tool). However, couldn't understand what it literally means by "stretchable patches" ? what exactly happens when you draw black dots outside the .png image ? (preview pane shows changes happening, but I am unclear on how it makes those)When I draw black dots in left/top sides of image it shows some changes in preview; but why isn't there any effect when you do the same on right/bottom side of the image ? why this tool is used primarily for background, when we try to process on the image itself ?i am trying to modify a simple button.png (given in android sdk). Whenever I use this tool & draw black lines, it reduces the size of the image instead of 'stretching' it! Why ?What is the significance of options given below like, "show lock", "show content", "Patch scale" and so on ?I apologize for asking so many questions, but in Android online docs they haven't explained well for novice. If someone can answer these, it will become ready reference for all the begineers who search this forum.
View 2 Replies
View Related
Jan 8, 2013
I am wondering if there is a way to draw an image, or edit simple lines in a text box. The entire screen is a textView/ect and i would like to be able to write a sentence then draw an image and write again. By draw i think i would use the Canvas, so basically is there a way to include a canvas in a text view?
Evernote does do this, but to edit an image/draw you need to open another app "Skitch", my goal is to try and do this without any extra apps.
For example:
Hello
(canvas/editable graphical items)
World
View 3 Replies
View Related
Jun 21, 2010
I want to have a elmenent with a 2 color border outline. I can do a single color outline using the element, but this only allows me to draw a single line. I tried using 2 elements within my but that didnt work either. Is there a way to either draw a shape within a shape or draw 2 lines around my shape (which has rounded corners btw).
View 3 Replies
View Related
Oct 5, 2010
I am trying to get two lines in the same row in a list view and I looked at some things online but found it hard to apply to what I am trying to achieve. Could anyone look at my code please and suggest me how I can make it possible. Code...
View 7 Replies
View Related
Jul 13, 2010
I am trying to put a background image and draw on top of that screen. I assumed activity will have a on draw method, but it does not have. it seems i need to use surfaceview. Can I put a surfaceview on top of the image view and make it transparent ? any example/tutorial i can refer to ?
View 5 Replies
View Related
Jan 4, 2010
I used the layout editor in eclipse to mock up my ui layout and then I created the code to populate it dynamically and things are showing up as different sizes. The XML I use to add the star images looks like this:
<ImageView
android:src="@drawable/star_gold"
android:layout_height="22sp"
android:layout_width="22sp"
android:adjustViewBounds="true"
android:layout_marginLeft="2sp"
android:layout_marginRight="2sp" />...............
View 4 Replies
View Related
Mar 29, 2010
I'm just getting started with developing for Android. I'm looking to port one of my iPhone applications, but I'm kind of at a loss for how to draw a view at runtime (a view not declared in the XML). Basically, I want to draw a simple rectangle, but then be able to manipulate its frame after being drawn. Sorry if this is a really, really simple question, but I can't seem to find some equivalent to the iPhone SDK here.
View 1 Replies
View Related
Jan 8, 2010
I am creating a android app using LunarLander as a example.Now I need to create a few buttons which are drawn over the view.I do not want them as a seperate layout above or below the view but in the custom view.Is this possible or am I going to have to programmatically show the button images then detect the touch. The buttons I create using new never show on the app. I assume this is because I have overwritten the onDraw and the buttons are never drawn even though I call.
View 3 Replies
View Related
Aug 9, 2010
How do I draw a view on top of image. There is a predefined android xml file and when I run the application I would like to bring up a dot or a square on the top of image. Here the image already shows up from pulling information from andrid res folder , how to draw an dot over it.
View 2 Replies
View Related
Jun 21, 2010
I have a class which extends a View and I'm drawing few images in the canvas. and i want to draw two buttons as well. could someone tell me how to do this? code...
View 3 Replies
View Related
Mar 4, 2010
Let consider this is my tile view (which is a bitmap):
0 0 0 0 0 0 0 0 0
First, I have change the view to
1 0 0 0 0 0 0 0 0
Second, I would like to change the middle one, and I expect the result is 1 0 0 0 1 0 0 0 0
However, the view give the result: 0 0 0 0 1 0 0 0 0
Is there any method that I can draw the particular part but now the whole view? code...
View 3 Replies
View Related
Aug 19, 2010
I have view, which have layout_width="wrap_content". If i use view.getWidth() in code, it returns 0.
How can I convert width of view "wrap_content" to pixels?
View 1 Replies
View Related
Dec 2, 2009
Between each row in list view, android draw a horizontal line (fades away at both ends). If I have a LinearLayout view, how can i add a border like that?
View 4 Replies
View Related
Dec 20, 2009
How to draw line on MapView given coordinates?
AFAIK, on iPhone it is possible.
View 1 Replies
View Related
Oct 29, 2010
I'm trying to create a MapView in a service (live wallpaper), but have it hidden so that I can render it to a Bitmap, and then map it to a texture to render in opengl. I have a Canvas and a Bitmap, and I intended to call myMap.draw(myCanvas) in order to get it into the correct bitmap so that I could then bind it as a texture.
When I Initialize I do the following:
myMap = new MapView(ctx, APPSTATICS.MAP_API_KEY);
I get an error:
java.lang.RuntimeException: stub at com.google.android.maps.MapView.<init> (Unknown Source)
Why I can't create a new mapview which I can use to draw to a offscreen bitmap?
View 7 Replies
View Related
Aug 9, 2010
How can I draw an dynamic view on top of mainscreen in android.
View 1 Replies
View Related
May 29, 2010
I have a simple program that draws the preview of the Camera into a SurfaceView. What I'm trying to do is using the onPreviewFrame method, which is invoked each time a new frame is drawn into the SurfaceView, in order to execute the invalidate method which is supposed to invoke the onDraw method. In fact, the onDraw method is being invoked, but nothing there is being printed (I guess the camera preview is overwriting the text I'm trying to draw).
This is a simplify version of the SurfaceView subclass I have:
public class Superficie extends SurfaceView implements SurfaceHolder.Callback {
SurfaceHolder mHolder; public Camera camera; Superficie(Context context) { super(context);
mHolder = getHolder(); mHolder.addCallback(this); mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
} public void surfaceCreated(final SurfaceHolder holder) { camera = Camera.open();
try { camera.setPreviewDisplay(holder); camera.setPreviewCallback(new PreviewCallback() {
public void onPreviewFrame(byte[] data, Camera arg1) { invalidar();
} } ); } catch (IOException e) {} } public void invalidar(){ invalidate(); }
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
Camera.Parameters parameters = camera.getParameters(); parameters.setPreviewSize(w, h);
camera.setParameters(parameters); camera.startPreview(); }
@Override public void draw(Canvas canvas) { super.draw(canvas);
// nothing gets drawn :( Paint p = new Paint(Color.RED);
canvas.drawText("PREVIEW", canvas.getWidth() / 2, canvas.getHeight() / 2, p);
} }
View 1 Replies
View Related
Sep 29, 2010
How can i draw a view on a canvas by giving the x,y position in the canvas.
For example,
I have custom view myView, which was created by inflating one of my layout.xml file.
Now i want to draw this myView on the canvas at position (x, y).
How can i do that? code...
View 1 Replies
View Related
Jul 6, 2010
My objective is to run a glowing animation on an image.I am changing the image alpha to produce this effect.
I have used basic AlphaAnimation provided in android framework but found that its slowing down other animations. So i extended a class from SurfaceView and created a thread to update it. ( Again here, i am manipulating alpha of the image ).
Everything seems fine, except that i am not able to draw a transparent image onto SurfaceView.Its showing black color on the transparent areas of the bitmap.code...
View 1 Replies
View Related
Oct 4, 2010
I am using a Gallery view where the view corresponding to each item is non-trivial and consists of text as well as multiple buttons. When I click to drag the gallery view (somewhere not on one of the buttons) the button's drawable state changes to pressed and appears as if all of the buttons are currently being pressed. Additionally, the same behavior happens for the selected state (e.g. all of the text of the child TextViews changes color). I am trying to prevent this behavior and have found the android:duplicateParentState xml attribute as well as the setDuplicateParentStateEnabled property. This seems like it should accomplish what I am trying to do, but it seems to have no effect.
View 1 Replies
View Related
Apr 5, 2010
I have a custom component which consists of 2 text view and 4 toggle buttons. I want to draw this view at some specific position on the screen. How is that possible?
View 1 Replies
View Related
Aug 23, 2010
I have a SurfaceView that is being used to draw images, and I would like to overlay them onto a live-feed from the phone's camera. Currently, the SurfaceView that contains the images have a white-background, but if I were to overlay them onto the phone's camera feed, they would have to be transparent. The camera and animation drawing cannot be done on the same SurfaceView. What is the best course to pursue the use of multiple views that involve managing the camera and drawing images? Is it possible to make a SurfaceView transparent?
View 4 Replies
View Related