2012-03-16 30 views
-1

我想要顯示圖像以保持當前背景透明,然後在某個時間後將其刪除。顯示圖像並在android中將其刪除

public void onCreate(Bundle savedInstanceState) 
{ 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 
     //shown an image while keeping the background visible 
     //call function and perform manipulation 
     //remove the image 
} 

我該如何做到這一點。

+1

來吧...這裏是你的工作? – 2012-03-16 04:42:12

回答

0

我從來沒有這麼做過,但也許你可以這樣做:

添加到您的活動:

Llayout = (LinearLayout) findViewById(R.id.layout); 
Llayout.findViewById(R.id.Imagebutton1).setVisibility(0); 
}; 

或致電:

Llayout.removeView(圖)

不要忘記在這個例子中聲明佈局的LinearLayout:佈局

linearLayout Llayout; 

導入庫:

進口android.widget.LinearLayout;與活動

<?xml version="1.0" encoding="utf-8"?> 
<resources> 


<style name="Theme.Transparent" parent="android:Theme"> 
<item name="android:windowIsTranslucent">true</item> 
<item name="android:windowBackground">@android:color/transparent</item> 
<item name="android:windowContentOverlay">@null</item> 
<item name="android:windowNoTitle">true</item> 
<item name="android:windowIsFloating">true</item> 
<item name="android:backgroundDimEnabled">false</item> 


</style> 
</resources> 

在清單中添加這種風格:

<activity android:name=".TestAppActivity" android:theme="@style/Theme.Transparent"/> 

主 - :

1

您可以通過這種方式執行此操作:

價值觀文件夾中創建styles.xml。 xml:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" android:layout_width="fill_parent" 
android:layout_height="fill_parent" android:weightSum="1"> 
<TextView android:layout_width="fill_parent" 
    android:layout_height="wrap_content" android:text="@string/hello" /> 
<ImageView android:layout_width="fill_parent" android:id="@+id/imageView1" 
    android:src="@drawable/icon" android:layout_weight="0.52" 
    android:layout_height="wrap_content"></ImageView> 
</LinearLayout> 

您的任何活動:TestAppActivity

package com.android.test; 

import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.view.View; import android.widget.ImageView;

public class TestAppActivity extends Activity第一次創建活動時調用。 */ 私人ImageView imgView; 私人處理程序處理程序;

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 
    imgView = (ImageView) findViewById(R.id.imageView1); 
    handler = new Handler(); 
    Thread t = new Thread(new Runnable() { 

     @Override 
     public void run() { 
      // TODO Auto-generated method stub 

      try { 
       Thread.sleep(500); 
      } catch (InterruptedException e) { 
       // TODO Auto-generated catch block 
       e.printStackTrace(); 
      } 

      handler.post(new Runnable() { 
       @Override 
       public void run() { 
        imgView.setVisibility(View.GONE); 
       } 
      }); 
     } 
    }); 

    t.start(); 
} 

}

相關問題