android自定义对话框
来源:互联网 发布:php 清空cookie 编辑:程序博客网 时间:2024/04/30 11:39
final Dialog dialog=new Dialog(HomeActivity.this,R.style.dialog_bg_style); //在第二个参数中自定对话框的style.
在资源文件styles.xml中添加一个自定义的style:
<style name="dialog_bg_style" parent="@android:style/Theme.Dialog">//继承对话框的style
<item name="android:windowFrame">@null</item> //设置前景
<item name="android:background">@drawable/button_pressed</item>//设置背景
<item name="android:windowIsFloating">true</item>//是否是悬浮窗类型
<item name="android:windowIsTranslucent">true</item>//设置是否透明
<item name="android:windowNoTitle">true</item>//去除对话框的标题
<item name="android:windowAnimationStyle">@+android:style/Animation.Translucent</item>//设置窗口出现的方式
</style>
接着定义自己的对话框(自己想怎么定义)
<?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="#FFFFFF">
<RelativeLayout android:id="@+id/dialog_one_tv_rl"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="@drawable/wallpaper">
<TextView android:id="@+id/dialog_one_tip_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="20sp"
android:gravity="center"
android:text="新建歌单"
android:background="@drawable/wallpaper"
android:layout_marginLeft="@dimen/margin_left"/>
</RelativeLayout>
<RelativeLayout android:id="@+id/dialog_one_listname_rl"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_below="@+id/dialog_one_tv_rl">
<EditText
android:id="@+id/dialog_one_listname_et"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginLeft="@dimen/margin_left"
android:layout_marginRight="@dimen/margin_left"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="@drawable/textview_bg"/>
</RelativeLayout>
<LinearLayout android:id="@+id/dialog_one_bt_ll"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="60dp"
android:gravity="center_vertical"
android:layout_below="@+id/dialog_one_listname_rl"
android:background="@drawable/wallpaper">
<Button android:id="@+id/dialog_one_positive_bt"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_weight="1"
android:text="确定"
android:background="@drawable/button_bg"
android:layout_marginLeft="@dimen/margin_left"
android:layout_marginRight="@dimen/margin_left"
/>
<Button android:id="@+id/dialog_one_nagtive_bt"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_weight="1"
android:text="取消"
android:background="@drawable/button_bg"
android:layout_marginLeft="@dimen/margin_left"
android:layout_marginRight="@dimen/margin_left"
/>
</LinearLayout>
</RelativeLayout>
最后 dialog.setContentView(view);完成 结果:
- android中的对话框:自定义对话框
- Android Dialog( 自定义对话框)
- android 自定义对话框
- android自定义对话框
- Android自定义对话框
- android 自定义对话框
- Android自定义Dialog对话框
- android自定义大小对话框
- android自定义对话框
- Android自定义对话框
- android 自定义对话框
- android 自定义对话框
- android自定义对话框
- android 自定义对话框动画
- Android弹出自定义对话框
- android自定义对话框
- android 自定义对话框
- Android自定义对话框
- [leetcode]Reverse Integer
- 【模电】电阻
- linux沙箱(sandbox)技术_百度文库
- Ubuntu 14.04 登陆界面一闪 返回登陆界面
- DOM和SAX的比较
- android自定义对话框
- 通用数据采集平台,从架构到代码
- 浅谈抽象与接口(含工厂、适配器、代理模式应用)
- 半监督学习
- OpenCart开发指南翻译 MVC-L架构简介 Introduction to MVC-L
- Android自定义控件系列二:自定义开关按钮(一)
- 《unix高级环境编程》文件和目录——文件权限
- 安卓巴士总结了近百个Android优秀开源项
- Windows server2012 (64位IIS)未在本地计算机上注册“Microsoft.Jet.OLEDB.4.0”提供程序