android 自定义Dialog去除标题栏
来源:互联网 发布:淘宝中老年新款女秋装 编辑:程序博客网 时间:2024/04/29 06:05
今天遇到自定义Dialog的问题,显示的Dialog顶部始终有一块区域不受控制,后来才知道,那是对话框的标题栏。当然,我是要去除这块区域的,后来在网上查询了一番,找到了一种方法解决这个问题,把她记录下来,以便日后参考。
对话框的布局:
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/psb" android:orientation="vertical" > <LinearLayout android:id="@+id/linearLayout1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="温馨提示:" android:textColor="#fff" /> <TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="150dp" android:text="您确定要退出程序吗?" android:textColor="#fff" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@+id/linearLayout1" android:layout_marginTop="172dp" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="确定" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="取消" /> </LinearLayout></RelativeLayout>
自定义对话框java代码:
package com.kv.network;public class dialogTest extends Dialog{/** * 通过主题样式来控制标题栏 * @param context * @param theme */public dialogTest(Context context, int theme) {super(context, theme);//加载布局文件this.setContentView(LayoutInflater.from(context).inflate(R.layout.dialog_content, null));}}
activity调用:
public class DA extends Activity{@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);//关键步骤,样式dialogTest d = new dialogTest(this,R.style.testDialog);d.show();}}
style:
<style name="testDialog" parent="@android:style/Theme.Dialog"> <item name="android:windowFrame">@null</item> <item name="android:windowNoTitle">true</item>//无标题 <item name="android:windowBackground">@null</item>//背景 <item name="android:windowIsFloating">true</item>//悬浮 <item name="android:windowContentOverlay">@null</item> </style>
如图
- android 自定义Dialog去除标题栏
- Android自定义Dialog去除烦人的标题栏和外框
- android V7包 Dialog去除标题栏
- Android dialog去除边框代码 & 自定义dialog
- Android dialog无标题栏样式style(for 自定义dialog)
- Android自定义Dialog去除黑色边框
- android 自定义Dialog去除黑边
- android 自定义Dialog去除黑色边框
- Android 自定义Dialog去除title导航栏
- android 自定义Dialog去除黑色背景
- (转)Android:去除自定义dialog的title
- Android随笔之标题栏的去除以及自定义
- Android 去除标题栏
- Android如何去除标题栏
- Android 去除标题栏
- Android去除标题栏、全屏
- android app去除标题栏
- Android程序去除标题栏
- 会场安排问题
- 数组、指针、指针数组、数组指针
- 阅读cin用法介绍的收获
- Oracle大表快速建立索引
- 《Lua 5.0的实现》第五章 - 函数和闭包
- android 自定义Dialog去除标题栏
- 八枚银币
- sap Fiori
- magento 关于时间/时区
- 哪些网络虚拟化技术适合现代网络?
- 上网代理
- CentOS6编译安装Nginx
- 三十分钟掌握STL
- python学习笔记:二