android 自定义Dialog(背景图等)
来源:互联网 发布:石材效果图设计软件 编辑:程序博客网 时间:2024/05/16 00:29
通常在一些应用中,我们需要自定义弹出框,android系统自带的弹出框色彩方面 比较单一。下面介绍一下如何能过xml的布局自定义dialog,很简单的实例:
代码如下:
1. mya_dialog.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.android.gif"
android:orientation="vertical"
android:layout_width="220px"
android:layout_height="176px"
android:background="@drawable/dailog_back"
android:id="@+id/layout_root"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon"
android:layout_marginLeft="10px"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="loading......"
android:gravity="center"
/>
</LinearLayout>
2.在activity中
AlertDialog myDialog = new AlertDialog.Builder(this).create();
myDialog.show();
//这里注意一定要先show dialog 再去加载 contentView。否则会出现异常。(requestFeature must
be called before add content)
myDialog.getWindow().setContentView(R.layout.main);
代码如下:
1. mya_dialog.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.android.gif"
android:orientation="vertical"
android:layout_width="220px"
android:layout_height="176px"
android:background="@drawable/dailog_back"
android:id="@+id/layout_root"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon"
android:layout_marginLeft="10px"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="loading......"
android:gravity="center"
/>
</LinearLayout>
2.在activity中
AlertDialog myDialog = new AlertDialog.Builder(this).create();
myDialog.show();
//这里注意一定要先show dialog 再去加载 contentView。否则会出现异常。(requestFeature must
be called before add content)
myDialog.getWindow().setContentView(R.layout.main);
- android 自定义Dialog(背景图等)
- android 自定义Dialog(背景图等)
- android 自定义Dialog(背景图等)
- Android随记------Dialog自定义背景等样式
- 自定义Dialog android Dialog
- android 自定义dialog的实现(自定义大小、去除黑色边框等)
- 【Android】Dialog以及自定义Dialog
- android 系统Dialog,自定义Dialog
- Android dialog无标题栏样式style(for 自定义dialog)
- Android自定义Dialog多选对话框(Dialog+Listview+CheckBox)
- android 自定义dialog 自定义dialog 宽度问题
- android 自定义checkbox 背景图无效的问题
- Android自定义Dialog(自定义主题、自定义布局)
- Android自定义View(1):对话框-Dialog
- Android 自定义 dialog
- Android 自定义 dialog
- Android 自定义 dialog
- Android 自定义Dialog分类
- 2011-08-03 Music Genre classification Scripts
- 解决一个在国内不能安装chrome扩展的问题
- web.xml
- atmega8 例程:USART串口通信
- 自定义对话框之一
- android 自定义Dialog(背景图等)
- java 类调用静态方法不需要实际对象存在吗,仅仅将类装载到内存中就可以了吗
- 提示数字,英文,中文等示例
- Android-自定义Dialog样式
- sun jdk内存泄露解析之java.lang.OutOfMemoryError: Java heap space
- 慎用一键修改hosts软件
- ajax强制不缓存的方法
- java中String的“==”和equals判断相等性
- 西安项目的配置