2014-01-26 30 views
-1

你好,我有一个与metaView在android的生命周期imageViews的一个提示。我如何创建一个imageview(例如),并在三秒后隐形或毁坏?我的图像位于xml文件中,消失的可见度很高,当您触摸到某个图像时,它们就会显示出来,但我只希望图像可见几秒钟。ImageView终生在Android与Metaio

我的问题是,我有一个方法,我想在屏幕上显示一个拍摄,然后,拍摄必须desapear。我不能等待,几秒钟后可见,因为metaio渲染是在另一个地方(我不知道在哪里)。我的imageView是在xml中,但不可见。

public void onDisparo(View v){ 
    laser = (ImageView) findViewById(R.id.imageLaser); 
    laser.setVisibility(View.VISIBLE); 
    } 

} 
+0

pleasea发布你的源代码和布局。 –

回答

0

您的意思是启动画面?

activity_splash.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/gradient_background" > 

    <ImageView 
     android:id="@+id/imgLogo" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:src="@drawable/logo" /> 


</RelativeLayout> 

SplashScreen.java

package androidsplashscreentimer; 

import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 
import android.os.Handler; 

public class SplashScreen extends Activity { 

    // Splash screen timer 
    private static int SPLASH_TIME_OUT = 3000; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_splash); 

     new Handler().postDelayed(new Runnable() { 

      /* 
      * Showing splash screen with a timer. This will be useful when you 
      * want to show case your app logo/company 
      */ 

      @Override 
      public void run() { 
       // This method will be executed once the timer is over 
       // Start your app main activity 
       Intent i = new Intent(SplashScreen.this, MainActivity.class); 
       startActivity(i); 

       // close this activity 
       finish(); 
      } 
     }, SPLASH_TIME_OUT); 
    } 

} 
+0

我只想让隐形的imageView,而不是所有的活动 – Angel

+0

** android:visibility =“false”**在xml文件中? –

+0

首先是不可见的,然后,当你点击一个按钮时,图像变得可见,并且我不会等待3秒钟就可以移除图像。 – Angel