android - Rendering a button over SurfaceView -


i've been looking on google on how this, i've gathered it's not easy 123 because surface view draw above it, solution people have said use xml layout , make layout , add surface view child , button child that. i'm lost on i'd love see code on how (i prefer looking @ examples , trial , error learning).

my xml file

<?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="fill_parent"> <framelayout  android:layout_width="fill_parent"  android:layout_height="fill_parent">  <button  android:id="@+id/menu"  android:layout_width="fill_parent"  android:layout_height="wrap_content"  android:text="menu" /> <android.game.gameview  android:layout_width="fill_parent"  android:layout_height="fill_parent"/> </framelayout> </linearlayout> 

i've got no code adding in button except see on xml (i've been doing lot of trial , error).

project works this: activity --> setcontentview(surface view) --> render gfx on ondraw

can please me this, once i've seen example on how 1 object i'll able other objects.

edit - solved o.k i've managed work out post http://www.mail-archive.com/android-beginners@googlegroups.com/msg11780.html

i had set content view xml file, , add constructs surface view work

i had similar display imageview over-top of surfaceview, , did follows:

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/layout"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:background="#ffffff">     <com.my.package.drawingcanvas     android:id="@+id/canvas"     android:layout_width="match_parent"         android:layout_height="match_parent"         android:focusable="true"         android:background="#ffffff" />     <relativelayout         android:id="@+id/toolbar_notification"         android:layout_width="match_parent"         android:layout_height="35dp"         android:layout_alignparentbottom="true"         android:layout_alignparentright="true"         android:gravity="center_vertical">         <imageview             android:id="@+id/toolbar_notification_icon"             android:layout_width="40dp"             android:layout_height="match_parent"             android:layout_alignparentbottom="true"             android:layout_alignparenttop="true"             android:layout_alignparentright="true"             android:contentdescription="@string/content_desc_save_icon"             android:gravity="center|center_vertical" />     </relativelayout> </relativelayout> 

this results in button floating on top of surfaceview on bottom-right corner.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -