Android :: FrameLayout For Drawing Overlays In Game?

Nov 15, 2010

I've got a game, a custom View class draws my gameboard. I'm thinking of drawing some elements on a separate layer above the gameboard. I could do this in the View's canvas code, but since they won't change frequently, was thinking of introducing a frame layout to display this top layer.I'm not sure which route to take, the only reason I wouldn't do the FrameLayout is because I'm not sure if it has an impact on battery life. Everytime onDraw() is called, the system probably has to do an alpha composition of the two layers. Is that more battery consuming than drawing the elements from that layer myself in my canvas on every frame? Hard to answer since I'm not sure how complex the drawing will be yet, any general opinions?

Android :: FrameLayout for drawing overlays in game?


Android :: Itemized Overlays - Not Drawing Collection But Refreshing?

Apr 22, 2010

I'm trying to write code that draws accuracy circles around a gps location based on a time param. I have no problem setting up the GPS, or of calculating how to draw the circles.What's been killing me is that the Overlays always overwrite one another.So I can never have more than one circle.I've looked at all the examples and tutorials online but they seem to be obsessed with putting in icons or with Drawing from some database or array.If I understood correctly I should be able to do itemizedoverlays and just draw as i go without having to track each readout in an array.

View 9 Replies View Related

Android :: Game Stutters When Drawing Outside Screen

Apr 25, 2010

I have a game built for 480x320 screen resolution. When playing the game on a phone with a higher screen resolution (480 x 800 or 480 x 856) the game automatically stretches to fit the screen which works great. Because of different screen dimensions there is a piece of the screen on the right side (game is in landscape mode) that is black, not used by the game. I want to fill this up with an image, so the whole screen is filled. I only draw that image on screens bigger than 480x320. This all works fine, the image is displayed exactly the way I want to. The only problem is that the game runs less smooth then it used to run. There are small stutters noticeable. When I just draw a rectangle instead of an image the same problem occurs. Does anyone have an idea why this is happening?

View 8 Replies View Related

Android :: Compensate Drawing Delay From Game Logic Updates

Aug 24, 2010

Now I have (1: the UI-loop, there my SurfaceView is placed), (2: a second thread, there the draw function from the UI-loop is called AND the update calculations from my Engine) and (3: the engine, there all the calculations stuff are).Now I wonder how the best and smoothest way to do the SurfaceView independent from the actual frame rate. How shall I do so it will compensate if there is a low frame rate?

View 2 Replies View Related

Android :: Drawing Bitmaps On Screen In Game Without Slow Performance

Sep 16, 2009

I want to make a tile based game for android. At the moment I am drawing each tile as a separate bitmap. I have a big for loop that reads from a string and draws different tiles depending on what character it finds to draw the level. I have allowed the user to scroll the screen using scrolling gestures. However the game is too slow. It takes a long time to update the screen after the user scrolls. I presume this is because it has to draw each tile's bitmap individually. What would be a faster way to draw the level? I was thinking I could merge all the tiles into one bitmap. But I don't know how to do this.

Anyway here is my code so you can see the problem:
package org.example.tutorial2d;
import android.app.Activity;
import android.os.Bundle;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.GestureDetector.OnGestureListener;
import org.example.tutorial2d.Panel;
public class Tutorial2D extends Activity implements OnGestureListener {
GestureDetector gestureScanner; Panel main;
/** Called when the activity is first created. */
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
gestureScanner = new GestureDetector(this);
//requestWindowFeature(Window.FEATURE_NO_TITLE);
main = new Panel(this); setContentView(main); }
@Override public boolean onTouchEvent(MotionEvent me) {
return gestureScanner.onTouchEvent(me); }
@Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
main.handleScroll(distanceX,distanceY); return true; }
@Override public boolean onDown(MotionEvent e) { return true;
} @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { return true;
} @Override public void onLongPress(MotionEvent e){
} @Override public void onShowPress(MotionEvent e) {
} @Override public boolean onSingleTapUp(MotionEvent e) { return true; } }

And the class that does all the work:
package org.example.tutorial2d;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.View;
import org.example.tutorial2d.Point;
public class Panel extends View {
private int scrollX = 0; private int scrollY = 0;
public Panel(Context context) { super(context);
} @Override public void onDraw(Canvas canvas) {
/*Bitmap scratch; //Drawable scratch;
//scratch = getContext().getResources().getDrawable(
// R.drawable.icon); canvas.drawColor(Color.BLACK);
//scratch.draw(canvas); int origin = 0;
scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5);
canvas.drawBitmap(scratch, origin, origin, null);
int width = scratch.getWidth(); int height = scratch.getHeight();
scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3);
canvas.drawBitmap(scratch, origin + width, origin - 32, null);
[Code]

View 3 Replies View Related

Games :: Drawing Or Pictionary Style Game

Oct 17, 2010

Is there a game for android in which a person draws stuff on screen and others users guess? I have a game like it on my sister's ipad but want one for my Samsung Epic. Game is super addicting! Please let me know!

View 4 Replies View Related

HTC Desire : Google Maps Earth Overlays - How To Add Overlays

Sep 23, 2010

I've searched here and on the interweb, but cannot find out how to add overlays (.kml files) into Maps or Earth. Can it even be done (shame if not) and if so, how do I do it.

EDIT: I've tried MyMapsEditor, but that doesn't run on Froyo.

View 2 Replies View Related

Android :: Two SurfaceViews In FrameLayout

Jul 27, 2009

I have two SurfaceViews in one FrameLayout. So they are stacked upon another. What I want to achieve is to use the lower SurfaceView as kind of background that is changing heavily, and the upper SurfaceView as annotation overlay. So the upper SurfaceView has a (small) number of quickly changing elements that I will draw. Somehow, I can always only see one of the SurfaceViews, depending on which one is top. I thought that SurfaceViews are always transparent, but it seems I am missing something here.Any thoughts on why I can't overlay two SurfaceViews?

View 9 Replies View Related

Android :: How To Port AbsoluteLayout To FrameLayout?

Mar 12, 2009

AbsoluteLayout has become obsolete, I need to convert it to FrameLayout.My problem is in AbsoluteLayout. LayoutParams, I can specify (x,y) in the constructor, which specify the location of my view during layout.How can I achieve using FrameLayout + FrameLayout.LayoutParams?

View 14 Replies View Related

Android :: FrameLayout And Positioning Children

Jan 26, 2009

i'm in final stage of writing my custom widget (quite similar to Home's sliding panel). it works quite well except one thing: i have some problems with positioning it in FrameLayout (see 3 rightPanel* Panels in main.xml in attached eclipse project).basically i don't like the idea i'm using there: setting layout_marginTop in panelHandle children.

View 2 Replies View Related

Android :: How To Display An Activity In Framelayout?

Nov 24, 2010

I am wrting an android application which displays some buttons dynamically in a linear layout with vertical orientation.When ever we click on any button a new activity should start in the same frame . How can this be possible ? can anyone help me in solving this issue.I will be waiting for reply.

View 1 Replies View Related

Android :: Error Inflating Basic Framelayout Only In1.5

Aug 16, 2010

I have the following layout in XML (splashscreen.xml):

CODE:............

When I try to execute it in Android 1.5 (executes correctly in all other versions) I get these errors:

CODE:.............

Line 5 corresponds to ImageView line. Do you have any idea why my program executes in all Android versions except 1.5?

View 1 Replies View Related

Android :: How To Align Child In Right Side In FrameLayout?

Nov 4, 2009

How to align the child in right side in FrameLayout ?

View 3 Replies View Related

Android :: Making Padding Dynamic In A FrameLayout

Apr 2, 2010

I'm following an example where the author hard coded a paddingTop to 370px. How do I make that paddingTop dynamic? When I run this in 2 AVDs with HVGA and WVGA80 I get the frame floating at different heights. I'd like to say something like paddingTop=80%, but that doesn't work.

View 1 Replies View Related

Android :: Place View Inside FrameLayout

Oct 3, 2010

I want to add a view inside a FrameLayout programmatically and to place it in a specific point within the layout with a specific width and height. Does FrameLayout support this? If not, should I use an intermediate ViewGroup to achieve this? My initial idea was to add an AbsoluteLayout to the FrameLayout and place the view inside the AbsoluteLayout. Unfortunately I just found out that AbsoluteLayout is deprecated.

View 2 Replies View Related

Android - Open New Activity From Extends Framelayout

Sep 23, 2012

I'm doing that sample: [URL] ....

I want to change at this line

public void onClick(View v) {layout.setVisibility(GONE);}
to
public void onClick(View v) {
Intent myIntentopen = new Intent(MainActivityold.class, MainActivitynew.class);
startActivity(myIntentopen);
}

but it dosn't work.

View 2 Replies View Related

Android :: How Can I Delete Black Shadow Above Framelayout In Tab Widget?

Sep 7, 2010

I have a problem with the tab widget. There is a shadow above the framelayout that's part of the tabwidget. How can I modify or delete this shadow.

View 4 Replies View Related

Android :: Center View In FrameLayout Doesn't Work

Oct 29, 2010

I have a FrameLayout in which I have 2 controls:

- a custom view which draws a image and some text on it

- a textview with a text

I want to center both in the FrameLayout but I can't manage to do it. The Texview is centered just fine, my cusom view remains on the left side, when I make it visible.

View 1 Replies View Related

Android :: Align Button To Bottom Right Of Screen Using FrameLayout?

Nov 8, 2010

I am trying to put the zoom controls of the map on the bottom right corner of screen. I could do it with RelativeLayout using both alignParentBottom="true" and alignParentRight="true", but with Framelayout I did not find any such attributes. How do I align it to the bottom-right of screen?

View 1 Replies View Related

Android :: Overlays Drawn On The Map

Jul 17, 2010

What I am trying to do - I am continuously getting a stream of lat/lng positions, I want to move a overlay item dynamically on the map based on the lat/lng in the stream. I am displaying the location of moving object dynamically on the map

I am putting my whole code in a while(true) loop and trying to read the stream every 5 seconds and refresh the overlays on the map. But overlay items are not shown until the function (either oncreate, or any onclickeventhandler etc) is completed. For example, test code, I am adding a single test overlay item when ever the user clicks on a button. If I put a wait(2000000) "after" I add overlays and invalidate the map, the overlay is not displayed until the time has elapsed and the function is completed.

View 5 Replies View Related

Android :: More Efficient Map Overlays

Nov 2, 2009

In my app I am drawing bus routes on top of a MapView. The routes have anywhere between a dozen and a few hundred GPS coordinates that describe the route that the bus takes. The problem I'm having is that once I draw out all these lines panning/zooming the MapView is incredibly slow (even clicking the 'Back' button takes a minute to happen). I'm not sure how relevant it is, but I put in some debug code then checked the logcat output and the MapView is repeatedly calling the draw() method of the Overlay whether anything has changed or not. This is happening several times a second and is causing a massive amount of garbage collection to happen (2-3 MB every second).

View 2 Replies View Related

Android :: MapView Overlays

Sep 28, 2009

My problem is my MapView becoming very laggy and so non-responsive at times, that Android thinks its hit deadlock and tries to close it.

I am adding 60 overlays to the map view and i originally thought that the icon size may be causing the problem by using up all the memory. When i decreased the overlay icon size, it did improve things, though it is still to slow to be usable. Has anyone experienced anything similar and have a workaround? There may be a better way of doing it other then extending the Hello MapView example.

View 8 Replies View Related

Android :: Possible To Remove All Overlays?

Sep 12, 2010

I have the following code to add an Overlay

myMapView.getOverlays().add(sites);
myMapView.invalidate();

I also have the following remove code where sites is a global variable.code...

Sometimes I am left with duplicates so would like a way to remove all overlays from a map, is this possible?

View 1 Replies View Related

Android :: MapView Draw Overlays

Feb 14, 2010

i have a problem with my mapView. my app reads "some" gps points out of a file and i want to draw a route (drawing lines between the gps point). If my file contains many gps points, my app works really slow. i think its working slow, because i draw all overlays. now i want to check, whether a point is visible in my mapView or not. so i have to get the mapCenter and Lat/lon span (getLatitudeSpan,..) !? how and where must i save my points and how can i check all my points (after my mapCenter has changed for example). Shall I save my points in a list (in my Overlay class??) and iterate through every list item and check, wheter its visible or not?

View 4 Replies View Related

Android :: Dynamic Pin Overlays In MapView

Oct 29, 2009

I've been reading the (shoddy) documentation for the Google Maps API (MapActivity et al), and I think I have roughly worked out how it works. It seems that if you want to add a marker overlay you can use ItemizedOverlay easily, but you have to add all your markers at once. There doesn't seem to be any way to remove them.

What I want to do is query markers from an online database as the user pans around (in the same way the actual map tiles are fetched). Is there a simple way to do this?

As far as I can tell I need to subclass Overlay and implement the draw method, but where is the best place to put the code that fetches new markers when the map is panned? There doesn't seem to be an onMapChanged() method anywhere. My best guess is MapController.onKey() but that seems wrong.

View 2 Replies View Related

Android :: MapView Overlays With Multitouch

Feb 17, 2010

I'm seeing a bug with overlays on MapView with the Nexus One. Pinch and zoom multitouch gestures don't scale my overlays until the user releases the gesture, at which point the overlay redraws itself. In contrast, the My Location overlay in Google Maps WILL scale during the gesture. Is there a way to fix this in my app, or is this a MapView bug?

View 2 Replies View Related

Android :: Overlays On A Mapview Not Shown

Mar 1, 2010

I followed the instructions from the google hellomapview tutorial. I get a working mapview etc. But the two items that are added to the map are not shown. It seems they are there somewhere because tapping at the specified location shows the message that was added to the items.

Here is my source code. It should be very close to the google tutorial source code.

CODE:.............

View 2 Replies View Related

Android :: Efficient Map Overlays In On Google Map

Nov 24, 2010

I want to do the following and am kind of stuck on these for a few days:

1) I was trying to draw poly lines ( I have encoded polylines, but have managed to decoded those) that move when I move the map(the only solution that I found was for Geopoints to be transformed into screen co-ordinateswhich wont move if I move the map !)

2) I have used helloItemizedOverlay to add about 150 markers and it gets very very slow.any idea what to do ? I was thinking about threads(handler)

3) I was looking for some sort of a timer function that executes a given function, say, every 1 minute or so.

4) I was also looking for ways to clear the Google map from all the markers/lines etc

View 1 Replies View Related

Android :: Map Performance Poor Because Of Many Overlays?

Apr 17, 2010

I have a map in my android application that shows many markers (~20-50). But the app performs very poor when i try to scroll/zoom (in Google Android Maps i did a sample search for pizza and there were also some 20-50 results found and i didn't notice any particular performance problems when zooming/scrolling through the map).

onCreate() {
....
drawable = this.getResources().getDrawable(R.drawable.marker1);
itemizedOverlay = new MyItemizedOverlay(drawable,mapView);
...
callWebServiceToRetrieveData();

createMarkers();
}..............................

View 4 Replies View Related

Android :: ImageView Clickable Overlays

Apr 14, 2010

I have a ImageView and draw some things on that view. Now I want to have the position of the click in the onClickListener. Although I think that's not really possible (storing the position in the onTouchListener is not working), I want to ask, if there is any other way to accomplish that? The goal is to have a image with some overlays, that should be clickable. I thought about AbsolutLayout, but that is depracated, so what now?

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved