Android AlertDialog去除白色边框代码

使用样式文件,在values 目录下新建styles.xml文件,编写如下代码:
< resources>

  < style name="dialog" parent="@android:style/Theme.Dialog">

  < item name="android:windowFrame">@null

  < item name="android:windowIsFloating">true

  < item name="android:windowIsTranslucent">false

  < item name="android:windowNoTitle">true

  < item name="android:background">@android:color/black

  < item name="android:windowBackground">@null

  < item name="android:backgroundDimEnabled">false

  < /style>

< /resources>

调用时,使用AlerDialog的接口类,Dialog 接口编写如下代码:
  Dialog dialog = new Dialog(SetActivity.this, R.style.dialog);

  dialog.setContentView(R.layout.test);

  dialog.show();

下面我们查看一下Dialog的源码文件,里面的构造函数为如下:
  public Dialog(Context context, int theme) {

  mContext = new ContextThemeWrapper(

  context, theme == 0 ? com.android.internal.R.style.Theme_Dialog : theme);

  mWindowManager = (WindowManager)context.getSystemService("window");

  Window w = PolicyManager.makeNewWindow(mContext);

  mWindow = w;

  w.setCallback(this);

  w.setWindowManager(mWindowManager, null, null);

  w.setGravity(Gravity.CENTER);

  mUiThread = Thread.currentThread();

  mDismissCancelHandler = new DismissCancelHandler(this);

  }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值