Activity透明主题,对话框透明

继承AppCompatActivity透明主题

  <style name="MyTransparent" parent="Theme.AppCompat.Light.NoActionBar">
        "android:windowBackground">@android:color/transparent 
        "android:windowNoTitle">true
        "android:windowIsTranslucent">true
        "android:backgroundDimEnabled">true
        "android:windowAnimationStyle">@android:style/Animation.Translucent 
    style>

对话框透明

 <style name="TransDialogStyle" parent="Base.Theme.AppCompat.Light.Dialog">
        
        "android:windowFrame">@null
        
        "android:windowIsFloating">true
        
        "android:windowIsTranslucent">false
        
        "android:windowNoTitle">true
        "android:windowBackground">@android:color/transparent
        
        "android:backgroundDimEnabled">false
    style>

如果不行,可以在使用的时候加上下面代码

  //去掉黑色半透明遮罩
  Window window = dialog.getWindow();
  window.setDimAmount(0f);
  window.setBackgroundDrawableResource(android.R.color.transparent);

你可能感兴趣的:(android)