因爲項目需要,所以寫了一個圓角對話框,可以自定義圓角半徑,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,如果有任何意見或建議,歡迎反饋,謝謝!