android - SurfaceView transparency not working properly -
i've read every webpage available on google, read 10+ stackoverflow posts on subject, still cannot working properly. i'm 99% there. there must simple i'm missing i've spent 4 hours on far no luck.
i'm working on main menu game i'm writing. want draw animation in center transparent surfaceview, black screen instead of seeing background. since surfaceview on top of linearlayout, i've played around every combination of background color , alpha setting -- nothing works.
like 10+ topics on stackoverflow mention, added this:
manimview = (surfaceview) findviewbyid (r.id.animationsurfaceview); manimview.setzorderontop(true); // necessary manimview.getholder ().setformat(pixelformat.transparent); surfaceholder sfhtrackholder = manimview.getholder (); sfhtrackholder.addcallback (this);
in callbacks this:
public void surfacechanged(surfaceholder holder, int format, int width, int height) { holder.setformat(pixelformat.transparent); } public void surfacecreated (surfaceholder holder) { holder.setformat(pixelformat.transparent); } public void surfacedestroyed (surfaceholder holder) { }
in paint routine this:
paint p = new paint (); p.setcolor (0); p.setstyle(paint.style.fill); c.drawcolor(0,android.graphics.porterduff.mode.clear);
(i know it's redundant, getting desperate)
well, what's weird surfaceview transparent, under circumstances.
this screen looks if put set linearview contains surfaceview have background texture under (i draw little man on top of surfaceview canvas after gets created):
this screen looks if set background of linearview under surface view have red color:
new data point! if set background of root linearlayout single color, works. i'm starting think has background?
this screen looks if set background of linearview under surfaceview transparent. why seeing background of root linearview in every part of window except surfaceview? utterly confused this.
this xml file:
<linearlayout android:background="@drawable/main_menu_background" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:gravity="top" android:id="@+id/mainsectionmenu" > <textview android:layout_width="match_parent" android:layout_height="0px" android:textappearance="?android:attr/textappearancelarge" android:text="luna puma" android:id="@+id/titletext" android:layout_gravity="center" android:textcolor="#ff6495ed" android:autotext="false" android:textsize="50dp" android:layout_weight=".3" android:gravity="center" android:background="@android:color/transparent"/> <linearlayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="0px" android:layout_weight=".5" android:background="@android:color/transparent" > <linearlayout android:orientation="vertical" android:layout_width="0px" android:layout_height="match_parent" android:layout_weight=".25" > <button android:layout_width="wrap_content" android:layout_height="0px" android:text="easy" android:id="@+id/easybutton" android:layout_gravity="center" android:layout_weight=".5" android:background="@android:color/transparent" android:textcolor="#ff6495ed"/> <button android:layout_width="wrap_content" android:layout_height="0px" android:text="medium" android:id="@+id/mediumbutton" android:layout_gravity="center" android:layout_weight=".5" android:textcolor="#ff6495ed" android:background="@android:color/transparent"/> </linearlayout> <surfaceview android:layout_width="0px" android:layout_height="match_parent" android:id="@+id/animationsurfaceview" android:layout_weight=".5" /> <linearlayout android:orientation="vertical" android:layout_width="0px" android:layout_height="match_parent" android:layout_weight=".25"> <button android:layout_width="wrap_content" android:layout_height="0px" android:text="hard" android:id="@+id/hardbutton" android:layout_gravity="center" android:layout_weight=".5" android:textcolor="#ff6495ed" android:background="@android:color/transparent"/> <button android:layout_width="wrap_content" android:layout_height="0px" android:text="more ..." android:id="@+id/morebutton" android:layout_gravity="center" android:layout_weight=".5" android:background="@android:color/transparent" android:textcolor="#ff6495ed" android:alpha="1" android:clickable="false"/> </linearlayout> </linearlayout> <framelayout android:layout_width="match_parent" android:layout_height="0px" android:layout_weight=".2"> </framelayout> </linearlayout>
it turns out very simple!
i did correctly. implemented properly.
i had forgotten earlier testing spacing , sizing of astronaut had cut out black square background texture happened exact same size of surface view!!!!
i looking @ correct texture along.
sigh!
Comments
Post a Comment