Android Did any event occur when Activity.setContentView finished rendering?

I am trying to get values ​​from myImageView.getImageMatrix() method when my activity is ready. I tried using the methods onCreate() , onStart() , onResume() , but the matrix that I get is the default value.

If I call myImageView.getImageMatrix() called by OnClickListener after my activity is visible, I get the correct values.


Just to be more clear:

  • call getImageMatrix onStart = Matrix{[1.0, 0.0, 0.0][0.0, 1.0, 0.0][0.0, 0.0, 1.0]}

  • call getImageMatrix onClick = Matrix{[0.77488154, 0.0, 7.6717987][0.0, 0.77488154, 0.0][0.0, 0.0, 1.0]}

+8
android events matrix image
source share
4 answers

You can also try this method:

 ImageView myImageView = (ImageView) findViewById(R.id.myImageView); ViewTreeObserver vto = myImageView.getViewTreeObserver(); vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { // do something now when the object is loaded // eg find the real size of it etc myImageView.getViewTreeObserver().removeGlobalOnLayoutListener(this); } }); 
+15
source share

I'm not 100%, but I needed to know something like this for my development, and I found out that onWindowFocusChanged () is called when the view is loaded. I'm not sure if this will fill your needs or not.

+4
source share

Perhaps you can use onLayoutChangeListener , but I'm not sure.

0
source share

Perhaps you can use AsyncTask (http://developer.android.com/reference/android/os/AsyncTask.html), which controls the loading of ImageView (maybe not equal to zero).

You can display the progess dialog in onProgressUpdate and then continue your code from onPostExecute.

0
source share

All Articles