Android 自定义Dialog
来源:互联网 发布:免费手机网络电话软件 编辑:程序博客网 时间:2024/06/07 01:08
自定义Dialog
根据需求定义自己的布局Dialog
定义布局
定义样式
创建类并继承Dialog
使用Dialog
定义布局
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="300dp" android:layout_height="wrap_content" android:gravity="center" xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical"> <LinearLayout android:layout_margin="15dp" android:layout_width="match_parent" android:orientation="vertical" android:background="@drawable/bg_alertdialog_talklogistic" android:layout_height="wrap_content"> <EditText android:id="@+id/dialog_talklocation_remark" android:layout_margin="10dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/anniubg4_n" android:textColor="@color/black" android:gravity="start|top" android:hint="@string/qtxdqwlbzxx" android:minHeight="80dp" android:padding="10dp" android:textColorHint="@color/ztys21" android:textSize="12sp" /> <TextView android:id="@+id/dialog_talklocation_btn" android:layout_width="match_parent" android:layout_height="40dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginTop="10dp" android:textColor="@color/white" android:text="@string/submitLocation" android:gravity="center" android:textSize="18sp" android:layout_marginBottom="10dp" android:background="@drawable/logistics_info_remarkbtnbg"/> </LinearLayout> <ImageView android:id="@+id/logistics_info_close" android:layout_marginTop="5dp" android:layout_marginRight="5dp" android:layout_width="25dp" android:layout_height="25dp" android:layout_alignParentRight="true" android:src="@drawable/ic_talklogistics_close" /></RelativeLayout>
定义样式
<style name="mystyle" 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:windowBackground">@color/logisticsInfoDialog</item> <item name="android:backgroundDimEnabled">true</item> </style>
创建类并继承Dialog
public class TalkLocationDialog extends Dialog { public TalkLocationDialog(Context context) { super(context); } public TalkLocationDialog(Context context, int theme) { super(context, theme); } public static class Builder { private Context context; public Builder(Context context) { this.context = context; } public TalkLocationDialog create() { //主题可以换 final TalkLocationDialog dialog = new TalkLocationDialog(context,R.style.mystyle); View layout = AppUtils.inflate(R.layout.alertdialog_talklocation); dialog.addContentView(layout, new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); dialog.setContentView(layout); return dialog; } }}
使用Dialog
TalkLocationDialog alertDialog = new TalkLocationDialog.Builder(WuLiuXinXiActivity.this).create();alertDialog.show();
阅读全文
0 0
- 自定义Dialog android Dialog
- 【Android】Dialog以及自定义Dialog
- android 系统Dialog,自定义Dialog
- android 自定义dialog 自定义dialog 宽度问题
- Android 自定义 dialog
- Android 自定义 dialog
- Android 自定义 dialog
- Android 自定义Dialog分类
- Android Dialog( 自定义对话框)
- Android自定义Dialog
- Android-自定义Dialog样式
- Android 自定义Dialog样式
- Android:自定义dialog
- Android 自定义dialog
- Android自定义Dialog对话框
- Android 自定义dialog
- Android自定义Dialog
- Android自定义Dialog
- 实现一个栈Stack,要求实现Push(出栈)、Pop(入栈)、Min(返回最小值的操作)的时间复杂度为O(1) /查找一个字符串中第一个只出现两次的字符
- C#web知识
- linux chmod 755的含义
- java(== and equals)
- 欢迎使用CSDN-markdown编辑器
- Android 自定义Dialog
- Java String
- 动态规划的背包问题 (共六题)
- TensorFlow 基本变量定义,基本操作,矩阵基本操作
- 大数加法 自定义函数
- vue.js使用总结
- python——asyncio模块实现协程、异步编程(二)
- java 泛型
- 最简单的 TensorFlow 代码,TensorFlow Hello World 。