I load in onCreate()
and ImageView by findViewById()
. The ImageView is set as INVISIBLE from XML and it should become visible in onStart()
by calling mImage.setVisibility(View.VISIBLE)
.
The strange thing is that the visibility is not changed whereas if I set GONE from XML the visibility is actually changed.
Is there something that I'm missing?
EDIT:
The code:
private class MyClass extends Activity {
...
private ImageView mImage;
...
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mImage = (ImageView)findViewById(R.id.imageViewCompass);
......
}
@Override
protected void onStart() {
super.onStart();
mImage.setVisibility(View.VISIBLE);
}
}
and from XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeBus"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/imageViewCompass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/mwImage"
android:visibility="invisible" />
</RelativeLayout>
I'm sorry but I realized my self that I was not clear enough. I'm using an OpenGL SurfaceView and I would not have believed it could be annoying to other Views.. It seems that the setVisibility()
method has some problems starting from View.INVISIBLE
when working on a layer above a SurfaceView..
Here I found the answer: https://stackoverflow.com/a/12655713/2402640