如何在 android 中延迟隐藏过渡图像

How to delay hiding a transition image in android

我正在处理这个任务,我想延迟隐藏这个 imageView 直到加载另一个视图。所以目前的问题是有一个拆分,它只是在等待它加载时显示一个黑屏,然后回头看。我尝试使用处理程序但是

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

    
 }

我认为更有效的方法是监听正在绘制的视图。绘制视图时,您隐藏此视图..那是对时间没有依赖性。

这样做的方法是

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
        } 
    });