项目要用到弹出框,还要和苹果的样式一样(Android真是没地位),所以就自己定义了一个,不是很像(主要是没图),但是也还可以。
废话不多说了,直接上代码
1、先看布局文件
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="20dp" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" android:background="@drawable/custom_dialog_background" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" android:orientation="vertical"> <TextView android:id="@+id/tv_title_custom_dialog" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="20dp" android:text="提醒" android:textColor="#000" android:textSize="18dp" /> <TextView android:id="@+id/tv_message_custom_dialog" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:text="您确定要取消订单吗" /> </LinearLayout> <View android:layout_width="match_parent" android:layout_height="0.5dp" android:layout_marginTop="20dp" android:background="#dfdfdf" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:id="@+id/btn_negative_custom_dialog" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="@android:color/transparent" android:text="取消" android:textColor="@android:color/holo_blue_dark" /> <View android:layout_width="0.5dp" android:layout_height="match_parent" android:background="#dfdfdf" /> <Button android:id="@+id/btn_positive_custom_dialog" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="@android:color/transparent" android:text="确定" android:textColor="@android:color/holo_blue_dark" /> </LinearLayout> </LinearLayout> </LinearLayout>
当前题目:Android自定义弹出框dialog效果-创新互联
网站URL:https://www.cdcxhl.com/article10/dpcpgo.html
成都网站建设公司_创新互联,为您提供ChatGPT、App设计、企业建站、网站策划、手机网站建设、标签优化
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联