private AlertDialog.Builder mVerBuilder;
private View mViewVer;
mVerBuilder = new AlertDialog.Builder(this, R.style.newPassword);
final AlertDialog alert = mVerBuilder.create();
LayoutInflater layoutInflater = LayoutInflater.from(this);
mViewVer = layoutInflater.inflate(R.layout.systemversion, null);
alert.setView(mViewVer);
alert.show();
WindowManager.LayoutParams lp = alert.getWindow().getAttributes();
lp.width = (int)getResources().getDimension(R.dimen.installation_dialog_width);
lp.dimAmount = ContactsUtil.DIM_AMOUNT_TRANSLUCENT;
alert.getWindow().setAttributes(lp);
alert.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
其中,R.style.newPassword就是去掉边框的关键,它的定义在res/values/style.xml里,内容如下:
<style name="newPassword" parent="@android:Theme.DeviceDefault.Light.Dialog">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
</style>