2012-03-16 5 views
-1

나는 현재 배경을 투명하게 유지하면서 이미지를 표시하고 언젠가 제거합니다.이미지를 표시하고 안드로이드에서 제거

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

이 어서 ... 당신의 작품은 어디에 있습니까? –

답변

0

나는 이것을 결코하지 않았다하지만 어쩌면 당신이 수행 할 수 있습니다

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

또는 전화 :

이 사용자의 작업에 추가

Llayout.removeView (보기);

이 예에서 레이아웃을 선언하는 것을 잊지 마세요있는 LinearLayout : 레이아웃의

linearLayout Llayout; 

가져 오기 라이브러리 :

수입 android.widget.LinearLayout;

1

이 방법으로이 작업을 수행 할 수 있습니다

값 폴더에 styles.xml을 만듭니다 -

<?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"/> 

주. 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; 

수입에는 android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.view.View; 가져 오기 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(); 
} 

}

관련 문제