Home > OS >  How to delay hiding a transition image in android
How to delay hiding a transition image in android

Time:01-11

I am working on this task and I want to delay hiding this imageView until another view is loaded. So currently the problem is there is a split where it’s just displaying a dark screen as it waits for it to load which looks back. I tried using a handler but

private fun animationFromPointA() {
     val transImageView = findViewById<ImageView>(R.id.trans_image_view)
   
         Glide.with(this)
             .load(file)
            // I have removed the onl oadFailed and onResourceReady
             .into(transImageView)

    
 }

CodePudding user response:

I think a more effective approach will be to listen to the view being drawn . When the view gets drawn you hide this view ..that was there is no dependency on the time.

The way to do this is

final LinearLayout layout = (LinearLayout) findViewById(R.id.YOUR_VIEW_ID);(use your own layout)
    ViewTreeObserver vto = layout.getViewTreeObserver(); 
    vto.addOnGlobalLayoutListener (new OnGlobalLayoutListener() { 
        @Override 
        public void onGlobalLayout() {
    
         // Put your imageview visibility code here
        } 
    });
  •  Tags:  
  • Related