最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android自定義彈窗提示效果

 更新時間:2021年09月12日 10:36:43   作者:Simon66991  
這篇文章主要為大家詳細(xì)介紹了Android自定義彈窗提示效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了Android 自定義彈窗提示的具體代碼,供大家參考,具體內(nèi)容如下

Java文件:

private void showSetDeBugDialog() {
        AlertDialog.Builder setDeBugDialog = new AlertDialog.Builder(this);
        //獲取界面
        View dialogView = LayoutInflater.from(this).inflate(R.layout.system_admin_psw_alert_dialog, null);
        //將界面填充到AlertDiaLog容器并去除邊框
        setDeBugDialog.setView(dialogView,0,0,0,0);
        //初始化控件
        TextView but_cancel = dialogView.findViewById(R.id.but_cancel);
        TextView but_confirm = dialogView.findViewById(R.id.but_confirm);
        //取消點擊外部消失彈窗
        setDeBugDialog.setCancelable(false);
        //創(chuàng)建AlertDiaLog
        setDeBugDialog.create();
        //AlertDiaLog顯示
        final AlertDialog customAlert = setDeBugDialog.show();
        //設(shè)置AlertDiaLog寬高屬性
//        WindowManager.LayoutParams params = Objects.requireNonNull(customAlert.getWindow()).getAttributes();
//        params.width = 200;
//        params.height = 200 ;
//        customAlert.getWindow().setAttributes(params);
        // 移除dialog的decorview背景色
        Objects.requireNonNull(customAlert.getWindow()).getDecorView().setBackground(null);
        //設(shè)置自定義界面的點擊事件邏輯
        but_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                customAlert.dismiss();
            }
        });
        but_confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                customAlert.dismiss();
            }
        });
    }

布局文件:

<?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="wrap_content"
    android:orientation="vertical"
    android:background="@drawable/fillet_fill_stroke">

    <ImageView
        android:layout_width= "38dp"
        android:layout_height="38dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="10dp"
        android:src="@mipmap/wenti"/>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:paddingTop="20dp"
        android:paddingBottom="20dp"
        android:textColor="#5C5C5C"
        android:textSize="20sp"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp"
        android:text="確定要退出嗎?"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#eee"/>

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

        <TextView
            android:id="@+id/but_cancel"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:textColor="#999"
            android:paddingTop="15dp"
            android:paddingBottom="15dp"
            android:text="取消"/>

        <LinearLayout
            android:layout_width="1dp"
            android:layout_height="match_parent"
            android:background="#eee"/>

        <TextView
            android:id="@+id/but_confirm"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:paddingTop="15dp"
            android:paddingBottom="15dp"
            android:textColor="#5C5C5C"
            android:textStyle="bold"
            android:text="確定"/>

    </LinearLayout>

</LinearLayout>

資源文件:

背景樣式

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

    <!--描邊設(shè)置-->
    <stroke android:color="@android:color/darker_gray"
        android:width="1px" />

    <!--填充設(shè)置-->
    <solid android:color="@android:color/white"/>

    <!--圓角設(shè)置-->
    <corners android:radius="15dp"/>

</shape>

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

枣庄市| 兴文县| 呼伦贝尔市| 辉县市| 望江县| 桐庐县| 班戈县| 泗洪县| 宜城市| 仁怀市| 仁怀市| 城口县| 赫章县| 阿拉善右旗| 北票市| 韶山市| 冕宁县| 汉阴县| 澄迈县| 新兴县| 固镇县| 吴桥县| 巴楚县| 安徽省| 江华| 惠东县| 溧水县| 搜索| 宁河县| 田林县| 宜州市| 石首市| 盖州市| 拜泉县| 荆州市| 洪泽县| 东乡县| 正阳县| 建湖县| 锡林郭勒盟| 弋阳县|