Android AlertDialog去除白色邊框

 

使用styles.xml風格:

 

Style.xml代碼 
<style name="dialog" parent="@android:style/Theme.Dialog">
  <item name="android:windowFrame">@null</item>
  <item name="android:windowIsFloating">true</item>
  <item name="android:windowIsTranslucent">true</item>
  <item name="android:windowNoTitle">true</item>
  <item name="android:background">@android:color/transparent</item>
  <item name="android:windowBackground">@android:color/transparent</item>
  <item name="android:backgroundDimEnabled">true</item>
  <item name="android:backgroundDimAmount">0.6</item>
 </style>
 android:backgroundDimAmount就是用來控制灰度的值,當爲1時,界面除了我們的dialog內容是高亮顯示的,dialog以外的區域是黑色的,完全看不到其他內容,系統的默認值是0.5,而已根據自己的需要調整

 

 使用AlertDialog的上層接口類:

 

Java代碼 
  1. Dialog reNameDialog = new Dialog(getContext(), R.style.FullScreenDialog);  
  2. LayoutInflater mLayoutInflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);  
  3. View reNameView = mLayoutInflater.inflate(R.layout.audiorecord_rename, null);  
  4. reNameDialog.setContentView(reNameView);  
  5. reNameDialog.show();  

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章