출처 : http://karukaru22.blog.me/140123913153

 style.xml

 

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="NewDialog">
     <item name="android:windowFrame">@null</item>
     <item name="android:windowBackground">@android:color/transparent</item>
     <item name="android:windowIsFloating">true</item>
     <item name="android:windowContentOverlay">@null</item>
     <item name="android:windowTitleStyle">@null</item>
     <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
     <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
     <item name="android:backgroundDimEnabled">false</item>
     <item name="android:background">@android:color/transparent</item>
 </style>
 
<style name="Theme.CustomDialog" parent="android:style/Theme.Dialog">
        <item name="android:windowBackground">@android:color/transparent</item>
    </style> 
 
</resources>

 public class ProgressActivity extends Activity {
    Context mContext = this;
    Dialog dilog ;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
      
       Circle c = new Circle();
        new Thread(c).start();
        dilog = new Dialog(this,R.style.NewDialog);
        //dilog =ProgressDialog.show(mContext, "", "잠시만 기달려주세요");
        LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
        View v = inflater.inflate(R.layout.progress_circle, null);
        dilog.setContentView(v);
        dilog.show();
    }
   
   
    private class Circle implements Runnable {
     
  @Override
  public void run() {

  try {
   Thread.sleep(10000);
   handler.sendEmptyMessage(0);
  } catch (InterruptedException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
   }
  }
     
    }
 
    private Handler handler = new Handler(){
     public void handleMessage(Message msg){
      if (msg.what == 0){
       dilog.dismiss();
       Toast.makeText(ProgressActivity.this, "완료~", 0).show();
      }
     }
    };
   
}

 

다이얼로그에 창을 투명하게 하고 거기다가 프레그시바를 붙인겁니다~

 

주의깊게 볼것은 다이얼로그에 스타일을 적용햇으며 스타일.xml에 보시면 transparent는 투명하게 해준다는 뜻입니다..

 

이걸 응용해서 액티비티 자체도 투명하게 할수 있습니다..

 


 

AndroidMainfest.xml에서

 

투명하게 원하는 액티비티에

 

  android:theme="@style/Theme.CustomDialog" 이렇게 주면된다.. 그리고 위에 style.xml도 마지막라인줄에 것을 적용시켜야함

 

 

+ Recent posts