本文實例講述了Android編程自定義圓角半透明Dialog的方法。分享給大家供大家參考,具體如下:
效果圖如下:

只是在實例化的時候使用帶樣式的構造函數即可
new MyDialog(GameActivity.this, R.style.dialog);
在value文件夾中添加mydialogthemes.xml
<?xml version="1.0″ encoding=" utf-8″?><resources> <style name="dialog" parent="@android:style/Theme.Dialog"> <item name="android:windowFrame">@null</item> <item name="android:windowIsFloating">true</item> <item name="android:windowIsTranslucent">false</item> <item name="android:windowNoTitle">true</item> <item name="android:windowBackground">@drawable/filled_box</item> <item name="android:backgroundDimEnabled">false</item> <item name="android:backgroundDimAmount">0.6</item> </style></resources>
其中@drawable/filled_box引用的filled_box.xml在drawable文件夾中
<?xml version="1.0″ encoding="utf-8″?><shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#9000″/> <stroke android:width="3dp" color="#ffff8080″/> <corners android:radius="30dp" /> <padding android:left="10dp" android:top="10dp" android:right="10dp" android:bottom="10dp" /></shape>
希望本文所述對大家Android程序設計有所幫助。
新聞熱點
疑難解答