android AlertDialog 弹窗自定义布局 点击外部不关闭弹窗

AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.content);
//  加载布局  MainActivity.content  对应  MainActivity.this
time_view = View.inflate(MainActivity.content, R.layout.time_long, null);
count_tiime = (TextView) time_view.findViewById(R.id.count_tiime);
count_tiime.setText(hms);
builder.setView(time_view);

// 点击遮罩层不关闭 即弹窗的外部  builder.setCancelable(true); 对应点击外部可关闭
builder.setCancelable(false);
builder.create().show();

在这里插入图片描述

在这里插入图片描述

可自定义 time_long.xml 布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="30dp">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="20dp"
        android:orientation="horizontal">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginRight="30dp"
            android:text="开始记录时间"
            android:textColor="#33b5e5"
            android:textStyle="bold"></TextView>

        <TextView
            android:id="@+id/start_tiime"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="开始记录时间"></TextView>
    </LinearLayout>
    <TextView
        android:id="@+id/count_tiime"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="开始时间"></TextView>
</LinearLayout>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值