当前位置: 代码迷 >> Android >> Android AlertDialog除去白色边框代码
  详细解决方案

Android AlertDialog除去白色边框代码

热度:91   发布时间:2016-05-01 14:33:19.0
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);  }
  相关解决方案