在自定义Dialog时显示的界面中老是有黑色的边框,下面就介绍使用style去除黑色边框方法。

首先在values/styles定义自定义样式:

  <style name="MyDialog" parent="@android:Theme.Dialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowBackground">@drawable/actionbar_item_background</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:background">#FFF</item>
</style>
<item name="android:windowBackground">@drawable/actionbar_item_background</item>这个是重点,只有添加了这个后才能去除黑色的边框

或者是自定义一个透明的背景图片,这样也可以去除黑色边框!

代码:

	static class MsgDialog extends Dialog implements
android.view.View.OnClickListener {
private String text; public MsgDialog(Context context, String text) {
super(context, R.style.MyDialog);
this.text = text;
} @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login_dialog);
TextView txt = (TextView) findViewById(R.id.login_dialog_txt);
txt.setText(text);
TextView confirm = (TextView) findViewById(R.id.login_dialog_btn);
confirm.setOnClickListener(this);
} @Override
public void onClick(View v) {
MsgDialog.this.dismiss();
} }

xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:background="#FFF"
android:orientation="vertical" > <TextView
android:id="@+id/login_dialog_txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="TextView"
android:textColor="@color/grey3"
android:textSize="18sp" /> <!-- 分割线 --> <View
android:id="@+id/view_division"
style="@style/Viewborder" /> <TextView
android:id="@+id/login_dialog_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:height="50dp"
android:text="确定"
android:textColor="@color/grey3"
android:textSize="20sp" /> </LinearLayout>

--------------------------------------------------------------------------华丽丽的分割线-------------------------------------------------------------------------

dialog自定义动画:

1、在style.xml中添加

    <style name="AA" parent="@android:style/Theme.Holo.Light.Dialog">
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowAnimationStyle">@style/dialogWindowAnim</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:backgroundDimAmount">0.4</item>
</style> <style name="dialogWindowAnim">
<item name="android:windowEnterAnimation">@anim/enter</item>
<item name="android:windowExitAnimation">@anim/exit</item>
</style>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500"
android:fromXScale="100%"
android:fromYScale="100%"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="50%"
android:toYScale="50%" > </scale>

2、anim/enter.xml

<scale
android:fromXScale="50%"
android:fromYScale="50%"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="100%"
android:toYScale="100%" >
</scale>

anim/exit.xml

3、在代码中

在DialogFragment的方法onCreateDialog中使用

AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(),
R.style.AA);

dialg自定义动画,ok

android 自定义Dialog去除黑色边框的更多相关文章

  1. Android 自定义Dialog 去除阴影

    自定义Dialog中添加下列代码: window.clearFlags( WindowManager.LayoutParams.FLAG_DIM_BEHIND);

  2. Android自定义 Dialog 对话框

    Android自定义Dialoghttp://www.cnblogs.com/and_he/archive/2011/09/16/2178716.html Android使用自定义AlertDialo ...

  3. android 自定义Dialog背景透明及显示位置设置

    先贴一下显示效果图,仅作参考: 代码如下: 1.自定义Dialog public class SelectDialog extends AlertDialog{ public SelectDialog ...

  4. Android—自定义Dialog

    在 Android 日常的开发中,Dialog 使用是比较广泛的.无论是提示一个提示语,还是确认信息,还是有一定交互的(弹出验证码,输入账号密码登录等等)对话框. 而我们去看一下原生的对话框,虽然随着 ...

  5. Android自定义Dialog(美化界面)

    前言:在做项目的时候,发现dialog界面太丑陋,从csdn上下载了一份自定义dialog的源码,在他的基础上对界面进行美化...有需要的朋友可以直接拿走 效果图如下: 主要代码: /** * 自定义 ...

  6. Android自定义Dialog及其布局

     实际项目开发中默认的Dialog样式无法满足需求,需要自定义Dialog及其布局,并响应布局中控件的事件. 上效果图: 自定义Dialog,LogoutDialog: 要将自定义布局传入构造函数中, ...

  7. Android自定义Dialog

    Android开发过程中,常常会遇到一些需求场景——在界面上弹出一个弹框,对用户进行提醒并让用户进行某些选择性的操作, 如退出登录时的弹窗,让用户选择“退出”还是“取消”等操作. Android系统提 ...

  8. Android 自定义Dialog类,并在Activity中实现按钮监听。

      实际开发中,经常会用到Dialog,比如退出时候会弹出是否退出,或者还有一些编辑框也会用Dialog实现,效果图如下: 开发中遇到的问题无非在于如果在Activity中监听这个Dialog中实现的 ...

  9. android自定义dialog布局

    dialog使用系统自带的有时候不是很美观,就想要自己来设计一个dialog界面,以下就是可以设计的dialog界面: public class CustomDialog extends Dialog ...

随机推荐

  1. Maven+JSP+SSM+Mysql+C3P0实现的学生管理系统

    项目简介 项目来源于:https://gitee.com/wu_yun_long/student_management_system 本系统是基于Maven+JSP+SSM+Mysql+C3P0实现的 ...

  2. Laravel - 上手实现 - 邮件发送

    Laravel 自带 SwiftMailer 库,集成了多种邮件API,可以很方便的实现邮件的发送. 我们使用到的是SMTP(Simple Message Transfer Protocol)简单邮件 ...

  3. 基于tcp协议的套接字通信:远程执行命令

    要解决粘包问题: TCP:流式协议 特点: 1.数据流没有开头也没有结果,像水流一样 2.TCP协议有一个nagle算法, nagle算法会将数据量较小,并且时间间隔较短的数据合成一条数据发送, 这么 ...

  4. 算法笔记刷题3(codeup 5901)

    今天刷题的速度依旧很慢(小乌龟挥爪.jpg) 我觉得codeup5901中回文串的处理很妙,如果是我自己写的话可能会把数组直接倒过来和原来对比.按照对称规律进行比对的话,工作量可以减少一半. #inc ...

  5. 6、Time & Window

    一.Time & Watermark 1.1.DataStream支持的三种time DataStream有大量基于time的operator Flink支持三种time: EventTime ...

  6. apt 安装 版本

    1. 通过apt-get安装指定版本软件 apt-get install package=version 2. 查询指定软件有多少个版本 2.1 通过网站搜索https://packages.ubun ...

  7. linux awk 命令实用手册

    0,简介 Linux awk 是一个实用的文本处理工具,它不仅是一款工具软件,也是一门编程语言.awk 的名称来源于其三位作者的姓氏缩写,其作者分别是Alfred Aho,Peter Weinberg ...

  8. 在IBM Cloud中运行Fabric

    文章目录 打包智能合约 创建IBM Cloud services 创建fabric网络 创建org和相应的节点 创建order org和相应节点 创建和加入channel 导入智能合约 上篇文章我们讲 ...

  9. nginx与keepalived实现高可用+Apache实现负载均衡

    nginx与keepalived实现高可用 本实验使用了四台虚拟机 两台需要安装nginx及keepalived 两台安装Apache nginx可以源码安装也可以用yum安装nginx yum安装n ...

  10. hdu_2391 Filthy Rich DP

    Filthy Rich Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...