android - Set SurfaceView behind the Drop Down List -
i want surfaceview
must appear behind options dropdown list [edit dimension etc.]. when tap on options on activity
surfaceview
should appear behind dropdown list.
please check image below link find problem surfaceview not appear behind option drop down list. easy understand questions.
please me how can this.
thanks in advance
image :
layout:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="match_parent" android:layout_gravity="center" android:orientation="vertical" android:weightsum="1" > <framelayout android:id="@+id/toplinearlayout" android:layout_width="fill_parent" android:layout_height="50dip" android:background="@drawable/bar" > <imageview android:id="@+id/new_quote_imageview" android:layout_width="match_parent" android:layout_height="wrap_content" android:src="@drawable/new_quote_bar" /> <textview android:id="@+id/new_quote" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="center" android:gravity="center" android:text="@string/new_quote" android:textcolor="@android:color/white" android:textsize="18sp" /> <textview android:id="@+id/optionstextview" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="right" android:layout_marginright="15dip" android:drawableright="@drawable/icn_dropdown_open" android:gravity="center" android:text="@string/options" android:textcolor="@android:color/white" android:textsize="18sp" /> </framelayout> <framelayout android:layout_width="fill_parent" android:layout_height="fill_parent" > <framelayout android:id="@+id/topframelayout" android:layout_width="fill_parent" android:layout_height="fill_parent" > <!-- imageview product --> <imageview android:id="@+id/photoimageview" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <com.amplimesh.renderer.rendererview android:id="@+id/renderer_view" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/transparent"/> </framelayout> <scrollview android:id="@+id/dropdownscrollview" android:layout_width="300dip" android:layout_height="wrap_content" android:visibility="gone"> <linearlayout android:id="@+id/dropdownlist" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/dropdown_background" android:orientation="vertical" android:paddingbottom="20dip" android:paddingleft="10dip" android:paddingright="10dip" android:visibility="gone" > <linearlayout android:id="@+id/editdimensionlayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginleft="10dip" android:layout_margintop="10dip" android:orientation="horizontal" android:weightsum="1" > <imageview android:id="@+id/leftimage" android:layout_width="30dip" android:layout_height="30dip" android:background="@drawable/left_image_drop_down" /> <textview android:id="@+id/dimensiontextview" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginleft="10dip" android:gravity="center_vertical" android:text="@string/edit_dimension" android:textcolor="@android:color/black" android:textsize="18sp" /> </linearlayout> <linearlayout android:id="@+id/editdimensionvaluelayout" android:layout_width="match_parent" android:layout_height="270dip" android:layout_marginleft="10dip" android:layout_marginright="10dip" android:layout_margintop="10dip" android:background="@drawable/edit_dimension_layout" android:orientation="vertical" android:visibility="gone" > <textview android:id="@+id/heighttextview" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginleft="12dip" android:layout_margintop="10dip" android:gravity="center_vertical" android:text="@string/height" android:textcolor="@android:color/black" android:textsize="16sp" /> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <edittext android:id="@+id/heightedittext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginleft="10dip" android:layout_margintop="10dip" android:maxwidth="180dip" android:minwidth="150dip" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginleft="10dip" android:gravity="center" android:text="@string/cm" android:textcolor="@android:color/black" android:textsize="14sp" /> </linearlayout> <textview android:id="@+id/widthtextview" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginleft="12dip" android:layout_margintop="10dip" android:gravity="center_vertical" android:text="@string/width" android:textcolor="@android:color/black" android:textsize="16sp" /> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <edittext android:id="@+id/widthedittext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginleft="10dip" android:layout_margintop="10dip" android:maxwidth="180dip" android:minwidth="150dip" /> <textview android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_marginleft="10dip" android:gravity="center" android:text="@string/cm" android:textcolor="@android:color/black" android:textsize="14sp" /> </linearlayout> <button android:id="@+id/savebutton" android:layout_width="100dip" android:layout_height="45dip" android:layout_gravity="center_horizontal" android:layout_marginleft="10dip" android:layout_margintop="10dip" android:background="@drawable/button_background" android:gravity="center" android:text="@string/save" android:textcolor="@android:color/white" /> </linearlayout> <linearlayout android:id="@+id/pickcolorlayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginleft="10dip" android:layout_marginright="10dip" android:layout_margintop="20dip" android:orientation="horizontal" android:weightsum="1" > <imageview android:id="@+id/leftimage" android:layout_width="30dip" android:layout_height="30dip" android:background="@drawable/left_image_drop_down" /> <textview android:id="@+id/pickcolortextview" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginleft="10dip" android:gravity="center_vertical" android:text="@string/pick_colour" android:textcolor="@android:color/black" android:textsize="18sp" /> </linearlayout> <relativelayout android:id="@+id/pickcolourvaluelayout" android:layout_width="match_parent" android:layout_height="330dip" android:layout_marginleft="10dip" android:layout_marginright="10dip" android:layout_margintop="10dip" android:background="@drawable/edit_dimension_layout" android:visibility="gone" > <imagebutton android:id="@+id/firstcolour" android:layout_width="100dip" android:layout_height="45dip" android:layout_alignparentleft="true" android:layout_marginleft="10dip" android:layout_margintop="10dip" android:background="@drawable/first_colour" /> <imagebutton android:id="@+id/secondcolour" android:layout_width="100dip" android:layout_height="45dip" android:layout_alignparentright="true" android:layout_aligntop="@id/firstcolour" android:layout_marginright="10dip" android:background="@drawable/tenth_colour" /> <imagebutton android:id="@+id/thirdcolour" android:layout_width="100dip" android:layout_height="45dip" android:layout_alignleft="@id/firstcolour" android:layout_below="@id/firstcolour" android:layout_margintop="15dip" android:background="@drawable/second_colour" /> <imagebutton android:id="@+id/fourthcolour" android:layout_width="100dip" android:layout_height="45dip" android:layout_alignparentright="true" android:layout_aligntop="@id/thirdcolour" android:layout_marginright="10dip" android:background="@drawable/ninth_colour" /> <imagebutton android:id="@+id/fifthcolour" android:layout_width="100dip" android:layout_height="45dip" android:layout_alignleft="@id/firstcolour" android:layout_below="@id/thirdcolour" android:layout_margintop="15dip" android:background="@drawable/third_colour" /> <imagebutton android:id="@+id/sixthcolour" android:layout_width="100dip" android:layout_height="45dip" android:layout_alignparentright="true" android:layout_aligntop="@id/fifthcolour" android:layout_marginright="10dip" android:background="@drawable/eight_colour" /> <imagebutton android:id="@+id/seventhcolour" android:layout_width="100dip" android:layout_height="45dip" android:layout_alignleft="@id/firstcolour" android:layout_below="@id/fifthcolour" android:layout_margintop="15dip" android:background="@drawable/fourth_colour" /> <imagebutton android:id="@+id/eightcolour" android:layout_width="100dip" android:layout_height="45dip" android:layout_alignparentright="true" android:layout_aligntop="@id/seventhcolour" android:layout_marginright="10dip" android:background="@drawable/seventh_colour" /> <imagebutton android:id="@+id/ninthcolour" android:layout_width="100dip" android:layout_height="45dip" android:layout_alignleft="@id/firstcolour" android:layout_below="@id/seventhcolour" android:layout_margintop="15dip" android:background="@drawable/fifth_colour" /> <imagebutton android:id="@+id/tenthcolour" android:layout_width="100dip" android:layout_height="45dip" android:layout_alignparentright="true" android:layout_aligntop="@id/ninthcolour" android:layout_marginright="10dip" android:background="@drawable/sixth_colour" /> </relativelayout> <linearlayout android:id="@+id/addmeshlayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginleft="10dip" android:layout_marginright="10dip" android:layout_margintop="20dip" android:orientation="horizontal" android:weightsum="1" > <imageview android:id="@+id/leftimage" android:layout_width="30dip" android:layout_height="30dip" android:background="@drawable/left_image_drop_down" /> <textview android:id="@+id/pickcolortextview" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginleft="10dip" android:gravity="center_vertical" android:text="@string/add_mesh" android:textcolor="@android:color/black" android:textsize="18sp" /> </linearlayout> <relativelayout android:id="@+id/addmeshcontentlayout" android:layout_width="match_parent" android:layout_height="200dip" android:layout_marginleft="10dip" android:layout_marginright="10dip" android:layout_margintop="10dip" android:background="@drawable/edit_dimension_layout" android:visibility="gone" > <button android:id="@+id/firstaddbutton" android:layout_width="60dip" android:layout_height="45dip" android:layout_alignparentleft="true" android:layout_marginleft="10dip" android:layout_margintop="10dip" android:background="@drawable/add_button_background" android:text="@string/add" android:textcolor="@android:color/white" /> <textview android:id="@+id/securameshtextview" android:layout_width="100dip" android:layout_height="45dip" android:layout_aligntop="@id/firstaddbutton" android:layout_marginleft="15dip" android:layout_marginright="10dip" android:layout_torightof="@id/firstaddbutton" android:gravity="center_vertical" android:text="@string/securamesh" android:textcolor="@android:color/black" /> <button android:id="@+id/secondaddbutton" android:layout_width="60dip" android:layout_height="45dip" android:layout_alignleft="@id/firstaddbutton" android:layout_below="@id/firstaddbutton" android:layout_margintop="15dip" android:background="@drawable/add_button_background" android:text="@string/add" android:textcolor="@android:color/white" /> <textview android:id="@+id/supameshtextview" android:layout_width="100dip" android:layout_height="45dip" android:layout_aligntop="@id/secondaddbutton" android:layout_marginleft="15dip" android:layout_marginright="10dip" android:layout_torightof="@id/secondaddbutton" android:gravity="center_vertical" android:text="@string/supamesh" android:textcolor="@android:color/black" /> <button android:id="@+id/removebutton" android:layout_width="100dip" android:layout_height="45dip" android:layout_below="@id/secondaddbutton" android:layout_centerhorizontal="true" android:layout_margintop="15dip" android:background="@drawable/button_background" android:text="@string/remove" android:textcolor="@android:color/white" /> </relativelayout> </linearlayout> </scrollview> </framelayout> </linearlayout>
code :
package com.amplimesh.renderer; import java.nio.bytebuffer; import java.nio.byteorder; import java.nio.floatbuffer; import javax.microedition.khronos.egl.eglconfig; import javax.microedition.khronos.opengles.gl10; import android.content.context; import android.graphics.pixelformat; import android.opengl.glsurfaceview; import android.opengl.glu; import android.util.attributeset; import android.util.log; import android.view.gesturedetector; import android.view.motionevent; import com.amplimesh.addproductsactivity; import com.amplimesh.models.objmodel; import com.amplimesh.util.mathhelper; import com.amplimesh.util.point3; public class rendererview extends glsurfaceview { public static final int grid_size=8; private context mcontext; private renderer mrenderer; private touchhelper mtouchhelper; float mviewwidth, mviewheight; objmodel mmodel; point3 morigin; point3 mrotate; point3 mcamera; floatbuffer mgrid; int mgridsize; public static string objname = ""; public static string texturefilename = ""; public rendererview(context context) { this(context,null); } public rendererview(context context, attributeset attrs) { super(context,attrs); mcontext = context; try{ mmodel = objmodel.loadfromstream(mcontext.getassets().open(objname), texturefilename); } catch (java.io.ioexception e) { log.v("demorendererview", "loading model: "+e); } morigin = new point3(0f,0f,0f); mrotate = new point3(0f,0f,0f); mcamera = new point3(0f,3f,3.9f); mtouchhelper = new touchhelper(context); } public void start() { mrenderer = new renderer(); seteglcontextclientversion(1); setrenderer(mrenderer); } @override public boolean ontouchevent(motionevent ev) { return mtouchhelper.ontouchevent(ev); } private void drag_xy(float dx, float dy) { morigin.x += (dx/mviewwidth)*mgridsize; morigin.y -= (dy/mviewheight)*mgridsize; float half = mgridsize/2; morigin.minmax(-half+.5f,-half+.5f,-half+.5f,half-.5f,half-.5f,half-.5f); } private void drag_xz(float dx, float dy) { morigin.x += (dx/mviewwidth)*mgridsize; morigin.z += (dy/mviewheight)*mgridsize; float half = mgridsize/2; morigin.minmax(-half+.5f,-half+.5f,-half+.5f,half-.5f,half-.5f,half-.5f); } private class touchhelper extends gesturedetector.simpleongesturelistener { gesturedetector gesture; int ptr1_id=-1, ptr2_id=-1; float last_x=-1, last_y=-1; public touchhelper(context context) { gesture = new gesturedetector(context, this); } @override public boolean ondoubletap(motionevent ev) { if (mrotationfinal != -1) return true; int index = ev.getactionindex(); float x = ev.getx(index); float y = ev.gety(index); int col = (int)(x / mviewwidth * 3); int row = (int)(y / mviewheight * 3); log.v("objdem", "col,row:"+col+","+row); if (col == 0 && row == 0) { mrotationaxis = z_axis; mrotationfinal = mrotate.z + 90; mrotationdelta = 1; } else if (col == 0 && row == 1) { mrotationaxis = y_axis; mrotationfinal = mrotate.y - 90; mrotationdelta = -1; } else if (col == 1 && row == 0) { mrotationaxis = x_axis; mrotationfinal = mrotate.x - 90; mrotationdelta = -1; } else if (col == 1 && row == 2) { mrotationaxis = x_axis; mrotationfinal = mrotate.x + 90; mrotationdelta = 1; } else if (col == 2 && row == 1) { mrotationaxis = y_axis; mrotationfinal = mrotate.y + 90; mrotationdelta = 1; } else if (col == 2 && row == 2) { mrotationaxis = z_axis; mrotationfinal = mrotate.z - 90; mrotationdelta = -1; } return true; } @override public boolean onfling(motionevent e1, motionevent e2, float vel_x, float vel_y) { float angle = mathhelper.angle_of_vector(vel_x, vel_y); log.v("objdemo", "vel: "+vel_x+","+vel_y+" = "+angle); return true; } public boolean ontouchevent(motionevent ev) { if(addproductsactivity.optionflag) { return false; } if (gesture.ontouchevent(ev)) { ptr1_id = -1; ptr2_id = -1; last_x = -1f; last_y = -1f; return true; } int action = ev.getactionmasked(); int index = ev.getactionindex(); int id = ev.getpointerid(index); int count = ev.getpointercount(); switch (action) { case motionevent.action_down: ptr1_id = id; break; case motionevent.action_pointer_down: ptr2_id = id; break; case motionevent.action_pointer_up: ptr2_id = -1; break; case motionevent.action_up: ptr1_id = -1; last_x = -1; last_y = -1; break; case motionevent.action_move: float x,y; if (count >= 2) { x = ev.getx(index); y = ev.gety(index); if (last_x != -1) drag_xz(x - last_x, y - last_y); } else { x = ev.getx(index); y = ev.gety(index); if (last_x != -1) drag_xy(x - last_x, y - last_y); } last_x = x; last_y = y; break; } return true; } } public final static int none=-1; public final static int x_axis=0; public final static int y_axis=1; public final static int z_axis=2; float mrotationfinal=-1f; float mrotationdelta=0f; int mrotationaxis=-1; private void tick() { if (mrotationfinal != -1) { float close = math.abs(mrotationdelta*2); switch (mrotationaxis) { case x_axis: mrotate.x += mrotationdelta; if (math.abs(mrotationfinal - mrotate.x) <= close) { mrotate.x = mrotationfinal; mrotationfinal=-1; } break; case y_axis: mrotate.y += mrotationdelta; if (math.abs(mrotationfinal - mrotate.y) <= close) { mrotate.y = mrotationfinal; mrotationfinal=-1; } break; case z_axis: mrotate.z += mrotationdelta; if (math.abs(mrotationfinal - mrotate.z) <= close) { mrotate.z = mrotationfinal; mrotationfinal=-1; } break; } //mrotate.minmax(-360,-360,-360, 360,360,360); } } private class renderer implements glsurfaceview.renderer { public renderer() { setalpha(0); setzorderontop(false); } public void onsurfacecreated(gl10 gl, eglconfig config) { gl.glclearcolor(0f,0f,0f, 0.5f); gl.glenable(gl10.gl_depth_test); gl.gldepthfunc(gl10.gl_lequal); gl.glhint(gl10.gl_perspective_correction_hint, gl10.gl_nicest); gl.glenable(gl10.gl_texture_2d); gl.glshademodel(gl10.gl_smooth); build_grid(grid_size); if(mmodel != null) mmodel.bindtextures(mcontext, gl); } public void onsurfacechanged(gl10 gl, int w, int h) { mviewwidth = (float)w; mviewheight = (float)h; gl.glviewport(0,0,w,h); gl.glmatrixmode(gl10.gl_projection); gl.glloadidentity(); glu.gluperspective(gl, 60.0f, mviewwidth/mviewheight, 0.1f, 100f); gl.glmatrixmode(gl10.gl_modelview); gl.glloadidentity(); } public void ondrawframe(gl10 gl) { tick(); gl.glclear(gl10.gl_color_buffer_bit | gl10.gl_depth_buffer_bit); gl.glpushmatrix(); //position camera glu.glulookat(gl, mcamera.x,mcamera.y,mcamera.z, morigin.x,morigin.y,morigin.z, 0f,1f,0f); //draw_grid draw_grid(gl); //draw_model gl.glpushmatrix(); gl.gltranslatef(morigin.x, morigin.y, 2); gl.glrotatef(mrotate.x, 1f, 0f, 0f); gl.glrotatef(mrotate.y, 0f, 1f, 0f); gl.glrotatef(mrotate.z, 0f, 0f, 1f); mmodel.draw(gl); gl.glpopmatrix(); gl.glpopmatrix(); } private void build_grid(int grid_size) { float i; float half = grid_size/2f; mgridsize = grid_size; bytebuffer tbuf = bytebuffer.allocatedirect((grid_size+1)*12*3 * 4); tbuf.order(byteorder.nativeorder()); mgrid = tbuf.asfloatbuffer(); (i=-half; <= +half; i++) { mgrid.put(i); mgrid.put(-half); mgrid.put(+half); mgrid.put(i); mgrid.put(-half); mgrid.put(-half); mgrid.put(i); mgrid.put(+half); mgrid.put(-half); mgrid.put(i); mgrid.put(+half); mgrid.put(+half); mgrid.put(-half); mgrid.put(i); mgrid.put(+half); mgrid.put(-half); mgrid.put(i); mgrid.put(-half); mgrid.put(+half); mgrid.put(i); mgrid.put(-half); mgrid.put(+half); mgrid.put(i); mgrid.put(+half); mgrid.put(-half); mgrid.put(+half); mgrid.put(i); mgrid.put(-half); mgrid.put(-half); mgrid.put(i); mgrid.put(+half); mgrid.put(-half); mgrid.put(i); mgrid.put(+half); mgrid.put(+half); mgrid.put(i); } mgrid.rewind(); } public void draw_grid(gl10 gl) { gl.glpushmatrix(); int ofs=0; int i; gl.gldisableclientstate(gl10.gl_texture_coord_array); gl.glvertexpointer(3, gl10.gl_float, 0, mgrid); (i=0; <= mgridsize*3; i++) { gl.gldrawarrays(gl10.gl_line_loop, ofs, 4); ofs+=4; } gl.glpopmatrix(); } } } package com.amplimesh.models; import java.io.bufferedreader; import java.io.ioexception; import java.io.inputstream; import java.io.inputstreamreader; import java.nio.bytebuffer; import java.nio.byteorder; import java.nio.floatbuffer; import java.util.arraylist; import java.util.stringtokenizer; import javax.microedition.khronos.opengles.gl10; import android.content.context; import android.graphics.bitmap; import android.graphics.bitmapfactory; import android.opengl.glutils; import android.util.log; import com.amplimesh.util.point3; public class objmodel { public void bindtextures(context context, gl10 gl) { bitmap bitmap; try { inputstream = context.getassets().open("textures/"+mtexturename); bitmap = bitmapfactory.decodestream(is); if (bitmap == null) { log.v("objmodel", "err loading bitmap!"); } } catch (java.io.ioexception e) { log.v("objmodel", "err loading tex: "+e.tostring()); return; } mtextures = new int[1]; gl.glgentextures(1, mtextures, 0); gl.glbindtexture(gl10.gl_texture_2d, mtextures[0]); gl.gltexparameterf(gl10.gl_texture_2d, gl10.gl_texture_min_filter, gl10.gl_linear); gl.gltexparameterf(gl10.gl_texture_2d, gl10.gl_texture_mag_filter, gl10.gl_linear); gl.gltexparameterf(gl10.gl_texture_2d, gl10.gl_texture_wrap_s, gl10.gl_clamp_to_edge); gl.gltexparameterf(gl10.gl_texture_2d, gl10.gl_texture_wrap_t, gl10.gl_clamp_to_edge); glutils.teximage2d(gl10.gl_texture_2d, 0, bitmap, 0); bitmap.recycle(); } public void draw(gl10 gl) { gl.glenableclientstate(gl10.gl_vertex_array); gl.glenableclientstate(gl10.gl_texture_coord_array); (model model : mmodels) { gl.glvertexpointer(3, gl10.gl_float, 0, model.v); if (model.vt != null && mtextures != null) { gl.glbindtexture(gl10.gl_texture_2d, mtextures[0]); gl.gltexcoordpointer(2, gl10.gl_float, 0, model.vt); } if (model.vn != null) { gl.glnormalpointer(gl10.gl_float, 0, model.vn); } gl.gldrawarrays(gl10.gl_triangles, 0, model.v_size); } gl.gldisableclientstate(gl10.gl_vertex_array); gl.gldisableclientstate(gl10.gl_texture_coord_array); } public static objmodel loadfromstream(inputstream is, string texture_name) throws ioexception { objmodel obj = objloader.loadfromstream(is); obj.mtexturename = texture_name; return obj; } private model mmodels[]; private int mtextures[]; private string mtexturename; }
in code setzorderontop(true); think explains everything, causes rectangle draw on top, that's why see that, should set false
setzorderontop(false);
and @ code should declare options dropdown list , call on it
... yourdropdownview.bringtofront();
Comments
Post a Comment