Android :: Animating A Drawable On A Canvas Inside A Surfaceview
Sep 2, 2010
Is there a way to animate drawables on a canvas using the android built-in animation classes?
Ive been modeling my test application, a game, after the example apps lunarlander and jetboy. They contain a lot of reusable code, but they manually update the drawable objects in real time. It seems like using the android animation built ins would be so much easier since they provide the type of animation I need¦a simple linear movement.
Is there a way to do this, or am I better off updating my canvas in real time much like the example apps.
If there is a way, could anyone get me started with some sample code? I am currently inheriting SurfaceView in my class.
View 1 Replies
May 19, 2009
I am using a SurfaceView, and wish to animate Drawables. All the animation tutorials I have seen concern using an ImageView, which as I understand is not a sensible approach from within a SurfaceView. Does anyone have any suggestions for doing frame-by-frame animation within a SurfaceView? Can it be done with openGL?
View 4 Replies
View Related
Sep 9, 2010
I am using SurfaceView to draw my game on the screen of the phone. Basically now I want to be able to draw Android Views on my View, such as a Button or ListView. I am simlpy getting a Canvas and then I draw on that... does anybody know how to draw AndroidViews (Button, ListView.) on my Canvas?
View 2 Replies
View Related
Oct 10, 2009
I am developing a chess game, what view should I use for the chessboard, Canvas or SurfaceView? I want to implement some animations like moving a piece, fading the chessboard or maybe rotating the chessboard.
View 4 Replies
View Related
Aug 20, 2010
When I set the background to my surfaceview, I see what I set as the background. However, I cannot draw simple things like circles when I lock/unlock the surfaceview's canvas. All I see is the background image.
View 1 Replies
View Related
Aug 27, 2009
I just got my camera preview working for my app, but it is not appearing where I want it to appear, and I'm not sure how to get it there. Instead of using the entire screen for the preview, I would like to put it inside a surfaceview in an activity xml gui. What do I need to change? Here is my code:
public class TakePic extends Activity {
SurfaceView camSurface;
Preview camPreview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);//hide window title
camPreview = new Preview(this); //create preview
setContentView(R.layout.takepic);
setContentView(camPreview); //set preview as activity content
camSurface = (SurfaceView) findViewById(R.id.camsurface); }
View 5 Replies
View Related
Sep 5, 2009
Is it possible to convert a Canvas to Drawable?I may be really off in my solution, so if you have a better suggestion, please do tell me. This is what I'm trying to do.I'm trying to create a custom RadioButton. to set different states of the radio button, I need to use this parameter and one of the parameter to addState is Drawable. I know I can easily provide an image file and use it as a Drawable, but I want to do some image manipulation to the image before using it.There is a tutorial in ApiDemo called AlphaBitmap. It uses the onDraw method of a View to change a PNG file to full red and draw something with a gradient. So I customized it to shade an icon with gradient. So the problem now is that this is a View, and the View works perfectly fine if I add this View to the main view. But i want to convert this View to Drawable so I can use it as one of the parameter in addState. What I really want to achieve is to have different colour shades for different state of the RadioButton without providing different images to do so.
View 6 Replies
View Related
May 26, 2009
I want to load an icon from resource and draw over it. But I cannot get it into a canvas. Can anyone please help me with the code below. If I uncomment c.drawColor(), I get blue color as expected. So the problem is on icon.draw(). code...
View 2 Replies
View Related
Sep 28, 2010
I have some images (.png format) that I use as drawables on the surface of canvas in my android app. The problem I have is mspaint only allows a rectangular image file, so whatever I draw on the screen always shows up in a box. Is there a (free) program or way I can edit the png files so that when they are drawn on the surface of my canvas, they are drawn to shape?
View 1 Replies
View Related
Nov 6, 2009
Or does it merely provide more options for graphics?
View 2 Replies
View Related
Oct 16, 2010
I've seen references to folks modifying the XML files contained inside the Android.jar.res.drawable folder and then copying them to their drawable folder for use in their project.
But I can't open these files, instead I get the following error.
Could not open the editor: org.eclipse.ui.PartInitException: Editor could not be initialized.
How do I open these files so I can use them?
View 2 Replies
View Related
Oct 18, 2009
This question was raised a few months ago here: http://groups.google.com/group/android-developers/browse_thread/threa... which suggests that animations cannot be done within an App Widget.
However, I'm sure I've seen some App Widgets animating... I have an App Widget which contains an ImageView. When the user clicks on this Widget I would like the ImageView to continuously rotate until a certain task (think synchronization) completes. This can take anywhere from a few seconds to a few minutes.
View 7 Replies
View Related
Nov 7, 2010
Basically what I am trying to accomplish is I want a canvas I can pass bitmaps to, to be displayed on the screen with the rest of my view objects (buttons, textviews, etc).
View 1 Replies
View Related
Mar 15, 2010
Does anyone how I go about detecting when a user presses on a bitmap which is inside a canvas?
View 2 Replies
View Related
Aug 20, 2010
One using a Surfaceview, and the other using a custom view. According to the android SDK development guide, using a surface view is better because you can spawn a separate thread to handle graphics. Th SDK development guide claims that using a custom view with invalidate calls is only good for slower animations, less intense graphics.However, in my simple app, I can clearly see that using a custom view with calls to invalidate seems to render faster.What do you guys know/think about this?My touchEvent code is exactly the same, and my drawing code is exactly the same. The only difference is that one is all in the UI thread, and the other is using a tread to handle the drawing.
View 1 Replies
View Related
Jul 7, 2010
My loadMap() method generate a canvas.throwIfRecycled exception when i try to load a new map.
When i start the game, the initial map loads and work fine though,
its only when i try to load a new map that i get the exception ..
How can i "reset" canvas and the bitmap i use to draw into, so i can startover fresh with them ?
here's what i use to create and draw my maps:
CODE:.........
So basicaly once i created and used picDest and canvas, i cannot figure how to reset it all for when i want to load a new map..
View 1 Replies
View Related
Oct 19, 2010
I am running my application in the emulator using a high density skin (like WVGA800). However the ressources in my application are loaded from the drawable- mdpi folder instead of drawable-hdpi ... what else should I do so that android use the correct folder ?
View 4 Replies
View Related
Oct 30, 2010
I've been a couple of days trying to solve this thing but I can'f figure it out.The problem is, simple activity, with simple layout, ScrollView -> LinearLayout -> and a lot of buttons inside the layout (within the scroll content). Everything works just fine but one tricky thing. When I click a button let's say at the top of the scroll content and inmediatelly I scroll down to the bottom of the content and I click other button there, nothing happens until I click a second time and all come to normal again.This can be reproduced anytime and it's code independent (i've tried more than 20 scenarios). I've not much experience in android yet but looks like the scroll listener stops the onclick listener or something like that.
View 1 Replies
View Related
Jul 7, 2009
So I've been extremely frustrated by this for a long time now.I've posted before, but can't seem to find a good solution. My goal is to have something pretty much exactly like the installed application details page in the Android Market.I need a list of items displayed along with other content above the list, and would like the content above to scroll up along with the list (exactly like the application details does for the "My Review" and other descriptive info).Due to responses to my previous posts, I came to believe that it really wasn't possible to do this with a ListView.So rather than using a ListView, I refactored my code to use a simple LinearLayout and add individual View items to the list, thinking I could just set each View as clickable and add an OnClickListener to each View in the LinearLayout.That's not working at all though, and now I'm getting even more frustrated.If someone can help me get the OnClickListener working, then I think it'll work, but I do need a separator for the LinearLayout.How do I add a separator like the one used for ListView to my LinearLayout?
View 12 Replies
View Related
Sep 17, 2010
Is it possible to animate the expanding and collapsing of the groups in a ExpandableListView.
View 3 Replies
View Related
Apr 8, 2009
How do I animate a Layout?
I have a RelativeLayout which sits in a certain position within my Activity; I want to glide it in and out from the bottom of the screen when a certain button is pressed.
I have found examples of animating the children of lists etc but this is not what I want. I simply want to animate the whole layout and the views within it together.
View 4 Replies
View Related
Jun 22, 2010
I have tried a weather widget and its working fine. The Weather widget is an app widget and I update the widget once in 6 hrs similar to the application on android site using AlarmManager. Now I want to animate the widget (ImageView) every 100 ms similar to HTC homescreen.
I dont think AppWidgets will scale well for this case. How can I implement this widget?
I have seen "Custom Homescreens" in previous Android SDK's. Should I have modify the Homescreen widget for doing this or is there any other way.
View 4 Replies
View Related
Aug 26, 2010
I'm drawing a ProgressBar in a custom View (SurfaceView) to it's Canvas, and it's drawn as expected. Except that it's not animating, no matter what I do. My custom view is animated properly, but I cant change the progress of the ProgressBar.
I've created the ProgressBar like this:
CODE:..................
And I draw it something like this (slightly simplified):
CODE:........
And I've tried updating it's progress manually as well:
CODE:.................
Any ideas on what I need to do in order for my ProgressBar to animate or change it's progress.
View 2 Replies
View Related
Nov 5, 2010
This is more of a question about animating than a specific problem coding. i need to fill in the broad strokes left by the research i've been doing.
What i'm trying to do:
The activity should load with only the a togglebutton visible. when the button is touched, a png will be animated to a certain position relative to the togglebutton. also, another button will slide in from off screen and slide off if/when the togglebutton is pressed again.
What i can't figure out:
I can draw an image, but only via xml. creating an imageview and setting the background programmatically does nothing.
When i draw from xml, i can't move the image when the togglebutton is pressed like i want to. when i call getPositionOnScreen() i get a null pointer, even though the complier can see i'm referring to the imageview described in both xml and in code.
I'm calling getPositionOnScreen because via xml, i have the image positioned behind the togglebutton so that it's not visible until the button has been pressed and the image starts moving. the idea is that with different screen sizes i won't know exactly where the view is until runtime. getPostionOnScreen allows me to get the coordinates of the imageview so i know where it has been positioned. when i have a start position, can tell it to "move up" on the screen from behind the togglebutton by simply adding to x or y until it's where i want.
This is the code to draw the image (inserted in the onCreate method).
CODE:.......
This is the code i'm using to animate. when the button is clicked, it calls this method on the view from the listener.
CODE:...............
I'm well aware that this is horribly wrong and won't work. what i need to understand is why.
View 1 Replies
View Related
Oct 6, 2010
I have a RelativeLayout with a tiled background. Is there a way to make a tween animation to fade out the existing image and fade in a new one?
View 1 Replies
View Related
Apr 27, 2010
Is there a way of being notified when a TransitionDrawable has finished its transition? I'm looking for a way to animate the background of a LinearLayout, switching it back and forth between two images thus creating a pulsating effect. TransitionDrawable works nicely, but....once. I tried stacking several 'item' in the XML defining the transition, but no luck. It justs fades from item 1 to item 2 and sits there. I'm wondering if I shouldn't implement a custom Animation.
View 3 Replies
View Related
Nov 10, 2010
Does anyone knows if it's possible to animate different views during the same animation: I have a linear layout containing 6 dices (each dice extends a textview) and I need to animate each dice to simulate a roll (each dice will rotate on itself). I know how to do this rotation on each dice by using 6 animations, but I want to group these animations in one, so that I would be able to add an animation listener to execute further instructions at the end of this animation. I tried with an animationset but didn't manage to do it.
View 2 Replies
View Related
Feb 3, 2010
I'm trying to do something which seems simple. I want to have a map view, with a menu that slides up from the bottom of the screen where settings (for overlay) can be adjusted. However when I use a TranslateAnimation to affect the y position of the LinearLayout (which holds the menu), the buttons in the LinearLayout move, but there "hit area" stays in the same position as they were before the animation.
CODE:.........
I've also looked into tweening the view's marginTop value, but haven't even been able to determine how that would be done.
View 1 Replies
View Related
Sep 29, 2010
I create a ProgressDialog in onCreateDialog() like so:
code:.........
Android, in its wisdom (or serious lack of it) decides to cache every dialog created through onCreateDialog(). Because of that, any subsequent call to showDialog(DIALOG_PROGRESS_ID) results in the same ProgressDialog instance being used but the animation has stopped working.
I've tried to re-set indeterminate in onPrepareDialog(), but that doesn't do anything. There is likewise no obvious method to call on the dialog instance that will reset the animation.
code:................
But maybe there is a way to get the ProgressBar itself and start it animating? so I tried the following after I asked this question:
code:........
But it didn't work either!
So, does anyone know if there is a way to restart animation on a ProgressDialog? If not, is there a way that I can force every showDialog() call to call onCreateDialog()? (this second question was answered by @TuomasR, but after pondering it I don't think this is a very good solution to my problem)
View 1 Replies
View Related
Sep 20, 2010
I am using android.hardware.Camera to get a preview and display it on a custom SurfaceView that implements SurfaceHolder.Callback.
I am trying to zoom in to the camera preview surface by a specified scale (not using the camera's digital zoom) but I can't seem to find a correct way to do it. I also need to be able to zoom out and scale down the preview.
I was hoping to be able to do this using a ScaleAnimation but it doesn't seem to work on SurfaceView, nor the FrameLayout containing the SurfaceView.
I also tried setting the size of the SurfaceView using setLayoutParams but that doesn't seem to work too well on various hardware and it would be tough to animate smoothly.
How to achieve this effect? Right now I am starting to think I might have to implement this using GLSurfaceView but I'm very unsure.
View 2 Replies
View Related