我有一个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。所以请帮助!
你需要SurfaceView与ImageView的可见??? – Jovan
是的,我需要imageview在SurfaceView顶部可见 –
好吧,我知道了!!在SurfaceView上放置一个surfaceView.setBackGroundColor(Color.TRANSPERANT),它允许显示ImageView,dat很奇怪! –