CircleDialog自定义弹框

闻人和歌
2023-12-01

CircleDialog自定义弹框

step1: 添加引用依赖

    implementation 'com.mylhyl:circleDialog:5.2.0'

step2: 主界面 弹框功能代码

package com.example.circledialogdemo;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;

import com.mylhyl.circledialog.CircleDialog;

public class MainActivity extends AppCompatActivity {
    // https://github.com/mylhyl/Android-CircleDialog
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    protected void onStart() {
        super.onStart();
        name1();
    }

    private void name1() {
        CircleDialog.Builder builder = new CircleDialog.Builder();
        builder.setTitle("是否删除该设备?");
        builder.setGravity(Gravity.CENTER);
        builder.setText("是否删除该设备");
        builder.setTextColor(Color.RED);
        builder.setCanceledOnTouchOutside(true);
        builder.setCancelable(true);
        builder.setWidth(0.75f);
        builder.setNegative("取消", view -> {
            Log.e("TAG", "setNegative");
        });
        builder.setPositive("确认", view -> {
            Log.e("", "setPositive");
        });
        builder.show(getSupportFragmentManager());
    }


}

end

 类似资料: