仿IOS圓角可自定義對話框

因爲項目需要,所以寫了一個圓角對話框,可以自定義圓角半徑,view和按鈕顯示。

1.效果截圖

在這裏插入圖片描述
在這裏插入圖片描述

2.添加依賴

1.Add it in your root build.gradle at the end of repositories:

	allprojects {
		repositories {
			...
			maven { url 'https://www.jitpack.io' }
		}
	}

2.Add the dependency

dependencies {
		implementation 'com.github.User:Repo:0.1'
	}

3.項目使用

1.創建對話框

RoundCornerDialogFragment fragment = RoundCornerDialogFragment.newInstance();
fragment.show(getSupportFragmentManager(), RoundCornerDialogFragment.class.getSimpleName());

2.設置各項配置信息

RoundCornerDialogHelperOption option = new RoundCornerDialogHelperOption.Builder()
                        .setTitleVisible(true)
                        .setCornerRadius(20)
                        .setBgColor(Color.RED)
                        .setLeftButtonTextColor(Color.GREEN)
                        .setOnRCDHClickLeftButtonListener(new OnRCDHClickLeftButtonListener() {
                            @Override
                            public void onClickLeftButton(RoundCornerDialogFragment fragment, AppCompatTextView v) {
                                Toast.makeText(MainActivity.this, "左邊", Toast.LENGTH_SHORT).show();
                            }
                        })
                        .setOnRCDHClickRightButtonListener(new OnRCDHClickRightButtonListener() {
                            @Override
                            public void onClickRightButton(RoundCornerDialogFragment fragment, AppCompatTextView v) {
                                Toast.makeText(MainActivity.this, "右邊", Toast.LENGTH_SHORT).show();
                            }
                        })
                        .build();
                RoundCornerDialogFragment fragment = RoundCornerDialogFragment.newInstance(option);
                fragment.show(getSupportFragmentManager(), RoundCornerDialogFragment.class.getSimpleName());

4.總結

具體的項目框架可以到GitHub上查看,https://github.com/MingYueChunQiu/RoundCornerDialogHelper.git,如果有任何意見或建議,歡迎反饋,謝謝!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章