Android :: Adding View Extending From SurfaceView To Layout Gives Blank Screen
Jun 5, 2010
I'm very new to Android programming, so this is probably something pretty basic. I just have an xml layout with a few buttons. I'm trying to follow the model given by the JetBoy demo, so I'm adding a view to the layout which extends SurfaceView. When this new view is put in my xml layout, I just get a blank screen.
Here's the XML layout if it helps. The gameview element is what causes the screen to be blank
CODE:......................
View 2 Replies
Aug 17, 2010
I want to build my own custom view which should look like the Crysis-GUI.At first I designed a XML-based Layout and made it visible via the setContentView(int resid)-Method. Worked pretty well.But now I wan't to go a step further and draw in my Layout. So I created a new Class, let it extend View and overrode the onDraw()-Method. So far so good.But how can I still use my XML-Layout? I can't do setContentView anymore, so how could the same effect be achieved?
View 1 Replies
View Related
Jul 30, 2010
I was informed in a later answer that I have to add the GestureOverlayView I create in code to my view hierarchy, and I am not 100% how to do that. Below is the original question for completeness.
I want my game to be able to recognize gestures. I have this nice SurfaceView class that I do an onDraw to draw my sprites, and I have a thread thats running it to call the onDraw etc .
This all works great.
I am trying to add the GestureOverlayView to this and it just isn't working. Finally hacked to where it doesn't crash but this is what i have
CODE:..........
The onGesturePerformed is never called. Their example has the GestureOverlay in the xml, I am not using that, my activity is simple:
CODE:................
So I am at a bit of a loss of the missing piece of information here, it doesn't call the onGesturePerformed and the nice pretty yellow "you are drawing a gesture" never shows up.
View 1 Replies
View Related
Mar 10, 2010
So my layout looks basically like this:
<ScrollView>
<RelativeLayout>
<BunchOfViews/>
<ImageView android:layout_alignParentBottom="true"/>
</RelativeLayout>
</ScrollView>
I have the ScrollView so all of the layout always is visible no matter the height of the screen. The problem is that on a very high screen, I still want my imageview to be at the bottom. However, a child of a ScrollView dont seem to have a defined bottom. The View is placed at the top of the layout. How can I solve this problem in a neat way?
View 4 Replies
View Related
Aug 15, 2009
I'm new to android development so sorry if this is a stupid question.
The SurfaceView doesn't seam to have an onMotionEvent to override. Is there anyway to capture onMotionEvents with a class extending SurfaceView?
View 2 Replies
View Related
Aug 18, 2010
I have a custom view (an extension of a TextView) that I want to dynamically add to my Layout (don't want to include it in the main.xml file).
The book says to fetch the RelativeLayout using findViewById() in my java code then create a new instance of my custom view, then use addView on the RelativeLayout to add the new view.
I'm not getting any errors, but when I click my button to add the new view, nothing is happening (view isn't being added). Do I need to set additional properties on my custom view (layout width, layout height for example) in order for it to be shown?
Adding code
CODE:............
View 1 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
Apr 1, 2010
How I can view apple movie trailers on website on my HTC desire as it appear to be blank screen? won't playback !
View 1 Replies
View Related
Apr 19, 2009
I want to add some views in each row of list view. When I add text view and image view in getView() of ArrayAdapter,it works. But after I add other kind of views (like Check Box and Image Button...), I can't select the list row touching down screen directly, I only can select by key down, up and ok.
View 2 Replies
View Related
May 6, 2010
I have an Activity which uses a layout with a LinearLayout in it. Now I want to create in runtime a subactivity which loads some other layout and add this layout as item of my LinearLatout.
View 1 Replies
View Related
Jun 6, 2009
I have a simple problem which makes me feel like a stupid. I really need help on this.
I have a SurfaceView which I created with Java code not XML. I created a MediaPlayer which shows its content on that SurfaceView.
When I use, setContentView(mPreview); // where mPreview is a SurfaceView
The video is played on the screen.
I need to add two buttons on the screen. So I tried something like this:
code:.........
This did not change anything. Still the video is displayed on full screen and no buttons appear. I am a java programmer both SE and ME. Things are done in this way on Java.
Does Android have a different approach?
View 4 Replies
View Related
Nov 14, 2010
I have two textviews, a listview (this is a listactivity, by the way) and a datepicker. All is supposed to be displayed in this order, vertically.
The problem is that the ListView is pushing the datepicker below the screen, to the depths of the unseen world. I want the datepicker to have its own space, fixed at the bottom, while the listview grows as needed, but still allowing datepicker to have its own space.
+/- like this:
~~~~~~~~~~~~~~~ screen top
TextView 1
TextView 2
|
|
|
| ListView [*]
|
|
|
DatePicker (stays here no matter how much List grows or shrinks
~~~~~~~~~~~~~~~ screen bottom
[*] -> This listview will scroll a lot, but won't hide datepicker!
I know it's very lazy to ask for ready code, but could you guys share a light? This is driving me crazy. I've tried millions of combinations I believe.
View 1 Replies
View Related
Apr 19, 2010
My application should hold a camera preview surface. The camera is fixed to landscape view via AndroidMainfest.xml I am quite new to the Android plattform programming. Of course I don't know much about the programming tricks and workarounds yet. I did a lot of research over the last two weeks (even studied the native Camera implementation), but couldn't find a good solution so far.
View 2 Replies
View Related
Oct 26, 2009
I am trying to extend a class in android.widget, specifically AbsSpinner class for some change in behavior. For that I need to access some protected members of the Classes up in the hierarchy, so I decided to put my new class in the same package android.widget It compiles fine in Eclipse but when I run it, it gives me java.lang.VerifyError. When I tried to find the cause, I came to know that this error is caused by the format of the class file different from what Android expects it to be.
View 9 Replies
View Related
Aug 7, 2009
When is it necessary, or better to use a SurfaceView instead of a View?
View 3 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
Mar 27, 2009
Code...
Is there a way to set the background of the SurfaceView just like a 2D view?
View 4 Replies
View Related
Mar 20, 2010
I need to draw a child view containing a rectangle and button on top of the content view at particular location on the parent (content view). How can I do this? Did not find an explicit way to set origin of child view?
View 1 Replies
View Related
Jan 23, 2009
Is it possible to build a GridView object in XML with 3 columns and 4 rows of Image buttons? It doesn't seem to have similar containment relationship like LinearLayout or RelativeLayout viewgroups.
I want to do this entirely in an xml layout file. When I put ImageButton xml tags inside a GridView xml body, The layout panel in eclipse is throwing an exception: UnsupportedOperationException:addView(View, LayoutParams) is not supported in AdapterView.
View 2 Replies
View Related
Oct 8, 2010
I have an XML layout with some custom tabs, a heading, and a ProgressBar(main.xml). I wish to add another XML layout(home.xml) to the main.xml layout, as i wish to keep main.xml re-usable for other activity's layouts and simply add things to it as necessary.The problem: after inflating R.layout.home into rootLayout, it seems as though the ProgressBar contained in rootLayout is hidden underneath the content of home.xml.Is there a way to tell certain views(via XML) to float above other views when the layout is constructed in this way?if not, am i forced to use methods such as progressBar.bringToFront() to raise targeted views to the top?what alternatives do i have in z-ordering views when some layouts are constructed using inflation?
View 2 Replies
View Related
Mar 11, 2010
I've tried to add a TextView before a ListView in a LinearLayout. The result is that the ListView wont show at all. The same thing happens if I put the TextView after the ListView, but then I will only see the ListView. Is there a way to get a text view above the ListView without to much of a hassle?
View 10 Replies
View Related
Nov 10, 2009
I have write a a.apk already, and there are a button in the a.apk that can trigger for b.apk, however b.apk is a freeware apk downloaded from the internet, now, I want to add a layout in the b.apk, such as left side is b.apk main program region, and right side is my new add layout region for a button, this button in the new layout region that can let users back to a.apk when click on.
View 2 Replies
View Related
Mar 9, 2010
I am developing under eclipse.When I add a new .xml file under a layout and build my application,the resources are not generated for that file under R.java consequently the new layout is not recognized.How do I fix this.
View 2 Replies
View Related
Aug 31, 2010
I need to load several ImageViews into a layout. The ImageViews are used to show a rating using 'star' icons. The number of stars (i.e. the rating is determined during loading by reading a configuration file.
The ImageViews are sitting inside a RelativeLayout layout.
Currently I am using something like this:
CODE:........
My quesions are:
1) Is doing the loading dynamically (not using an xml) is the 'right' way of doing this ?
2) If it is, how do I make the stars display in a line, currently they get placed one on top of the other.
View 3 Replies
View Related
Jan 26, 2009
I am probably missing something totally obvious, but can someone tell me how to add padding between buttons of a Linear Layout?
Code...
View 5 Replies
View Related
Sep 15, 2010
I was looking over this code about extending an ImageView: http://marakana.com/forums/android/examples/98.html
And i was wondering how can i add the new View to an existing xml layout file, along with some other views.
Already i did this inside my main linear layout:
CODE:..........
But the problem is that this way the onDraw method doesn't get called.
Maybe some examples where you combine CustomViews with xml layout.
View 2 Replies
View Related
Nov 21, 2010
I am using a flipper in my main xml file to view multiple layouts in my app. For instance, if something = 1, the user is shown one version of the flipper, where if something = 2 the user sees a different version. Is there a way I can view the layout of the xml file for the other flippers I have rather than the main one? Ie, is there a way to switch views of each state of the flipper in eclipse?
View 1 Replies
View Related
Sep 12, 2009
I have a LinearLayout defined in XML that I want to use repeatedly to display elements of a list. The XML-layout looks like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/background"
android:paddingBottom="5px">
<TextView
android:id="@+id/destination"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="22dp"
android:text="@string/test_destination"
android:paddingLeft="5px"/>
<TextView
android:id="@+id/date"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="15dp"
android:text="@string/test_date"
android:paddingLeft="5px"/>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/info"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="5px"
android:paddingTop="10px" >
I gather information about certain events from a webpage, and then I want to display all events in a list using the above layout for each event. My current approach is to have a LinearLayout as parent and then adding each event as a row.
Problem number one is to add the layout to each event (the number of events is varying). I.e., I want to dynamically inflate this layout for each event. I also don't want the text to be hard coded into the layout (as above) but added at runtime. I don't know how to do this. I have tried something like the following without any success.
LinearLayout eventView = (LinearLayout) findViewById(R.layout.event);
parentView.addView(eventView);
Problem number two is then to add these layouts to the parent view group and display it on the screen. When I try to do this using parent.addView(child), the program crashes at runtime and I can't figure out why.
It's kind of hard to describe the specific problem, since I'm new to GUI-programming on Android and I'm sort of programming by trial and error right now. Anyway, if you are able to help me with some of the problems it would be greatly appreciated. Linus
EDIT:
The problem now is adding text dynamically to the TextViews. I try this:
TextView dest = (TextView) findViewById(R.id.destination);dest.setText("myText");
only to discover that dest is null. Any ideas why and how to fix this?
EDIT 2:
I have narrowed the problem even more, but I really don't understand its nature. This is the trouble-method: Code...
it somehow works (even though the events are displayed in reverse order). Anyone knows what's going on here?
View 2 Replies
View Related
Oct 18, 2010
Is there a way to extend the delay of the pattern/PIN screen lock to several hours? Lock Delay does this for 2.1, but I read that it doesn't work well with Froyo.
View 1 Replies
View Related
May 4, 2010
I am new in android, i am having few problem in layout alignment. I have divide the screen into three layout,as header, body and footer. I am giving the height dynamically for the three layout in java file, so i need to give 12% of height to header and footer layout, and the remaining 75% i need to assign height to body layout. For that i have made the calculation as follow
first i am getting the height and width for the screen. With the help of the screen height i am getting the 12.5% height for header and footer layout
WindowManager w = getWindowManager(); Display d = w.getDefaultDisplay(); int totalwidth_screen = d.getWidth(); int totalheight_screen = d.getHeight();..................
View 3 Replies
View Related