new AlertDialog.Builder(mContext).setView(linearlayout).show();
来源:互联网 发布:淘宝1万多的充气娃娃 编辑:程序博客网 时间:2024/04/29 21:09
//用Dialog 用R.style.dialog 可以去除白边 不能用 new AlertDialog.Builder(mContext).setView(linearlayout).show();去做
样式文件,在values 目录下新建styles.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">false</item>
<item name="android:windowNoTitle">true</item>
<!--<item name="android:background">@android:color/black</item>-->
<item name="android:windowBackground">@null</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
调用时,使用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);
}
这里面我们可以看出,Android 使用了默认的构造函数为Dialog 设置样式,如果没有为其设置样式,即默认加载事先编写好的样式文件,Dialog 一共由多个9.png的图片构成,大部分都是带有边框的9.png图片,所以就是为什么我们上边的样式文件要将其背景去除掉。这个东西搞了我好久,希望对你有帮助
- new AlertDialog.Builder(mContext).setView(linearlayout).show();
- new AlertDialog.Builder 提示错误
- 关于Android AlertDialog的setView
- AlertDialog实现setView及点击事件
- Dialog.setContentView( View ) AlertDialog.setView( View ) 区别
- 关于AlertDialog的setView与setContentView区别
- 兔子--The constructor AlertDialog.Builder(new View.OnClickListener(){}) is undefined
- the constructor AlertDialog.Builder(new View.OnClickListener() ) is undefined
- new AlertDialog.Builder(this).setxx引发的胡思乱想
- AlertDialog.Builder
- AlertDialog.Builder
- AlertDialog.Builder
- AlertDialog.Builder
- AlertDialog.Builder
- AlertDialog和AlertDialog.Builder
- Android的AlertDialog,setView后去除黑色边框
- android中AlertDialog 中setView用法的一些小结
- Android的AlertDialog,setView后去除黑色边框
- 解决SQL Sever 2008装不上问题
- make&&gcc/g++ 生成 map file
- 游戏开发常用算法
- 如何快速把安卓应用移植到BlackBerry 10上
- 数制转换
- new AlertDialog.Builder(mContext).setView(linearlayout).show();
- 使用工具将安卓Android apk应用转换成Bar BlackBerry 10格式
- [其他-1] GitHub “Fork + Pull”模式
- 两程序员不同境遇:少抱怨 多解决问题
- 高斯函数 --> 高斯分布(正态分布)
- c#学习体会:使用 ref 和 out 传递数组(downmoon)
- C++中的IO流
- Lesson 1 Excuse me !
- 关于Core Data框架的基本概念解析