2011-09-06 83 views
1

我有一个framelayout,其中有surfaceView和ImageView,ImageView是不可见的。基于某些事件,ImageView必须变得可见。但它并没有到达前台。我知道图像已经变得可见了,因为我可以在日志中看到它,但它没有显示,因为它不在顶部,SurfaceView。那么我怎样才能把ImageView带到最顶端?这是我的代码。在framelayout中将imageView带到顶部

公共无效的onClick(视图v){

if(v.getId() == R.id.Button1) { 

     Toast.makeText(getApplicationContext(), "Button1", Toast.LENGTH_SHORT).show(); 

     image = (ImageView) findViewById(R.id.lockIcon1); 

     if(!icon1show) { 
      icon1show = true; 
      image.setVisibility(View.VISIBLE); 
     }else { 
      icon1show = false; 
      image.setVisibility(View.INVISIBLE); 
     } 

    }else if(v.getId() == R.id.Button2) { 

     Toast.makeText(getApplicationContext(), "Button2", Toast.LENGTH_SHORT).show(); 

     image = (ImageView) findViewById(R.id.lockIcon2); 

     if(!icon2show) { 
      icon2show = true; 
      image.setVisibility(View.VISIBLE); 

     }else { 
      icon2show = false; 
      image.setVisibility(View.INVISIBLE); 

     } 

    } 
} 

XML代码:

  <ImageView android:id="@+id/lockIcon2" 
         android:src="@drawable/lockicon" 
         android:visibility = "invisible" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content"/> 
      <SurfaceView android:id="@+id/far_end" 
         android:layout_height="217.33dip" android:layout_width="291dip"/> 



    </FrameLayout> 

现在从 “lockIcon2” 的图像没有显示是有SurfaceView连同在frameLayout中的imageView。所以请帮助!

+0

你需要SurfaceView与ImageView的可见??? – Jovan

+0

是的,我需要imageview在SurfaceView顶部可见 –

+0

好吧,我知道了!!在SurfaceView上放置一个surfaceView.setBackGroundColor(Color.TRANSPERANT),它允许显示ImageView,dat很奇怪! –

回答

2

请添加一段代码,以便我们为您提供帮助。你使用bringToFront()方法吗?

+0

嗨,我添加了您请求的代码。我尝试使用bringToFront()方法,但没有用! –

+0

这似乎没有回答这个问题 – JaviCasa

0

我完全不理解你,但我认为你需要将你的SurfaceView消失,而不是隐形。当看不见它会占据屏幕上的位置。试试这个...

相关问题