2014-01-26 29 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