Tôi muốn thực hiện một tùy chỉnh Dialog
. Bởi vì tôi không thích phong cách của nó, tôi muốn có hình chữ nhật tròn hơn là các góc nhọn. Tôi biết làm thế nào để thực hiện nó theo chủ đề trong AndroidManifest.xml
, ví dụ, tôi sử dụng:Tùy chỉnh hộp thoại bằng cách mở rộng Hộp thoại hoặc AlertDialog
android:theme="@style/Theme.CustomDialog"
Và Theme.CustomDialog.xml
:
<style name="Theme.CustomDialog" parent="android:style/Theme.Dialog">
<item name="android:windowBackground">@drawable/filled_box</item>
<item name="android:windowNoTitle">true</item>
filled_box.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#ffffffff"/>
<stroke android:width="3dp" color="#ffff8080"/>
<corners android:radius="30dp" />
<padding android:left="10dp" android:top="10dp"
android:right="10dp" android:bottom="10dp" />
</shape>
Làm thế nào tôi có thể thực hiện một kết quả tương tự bằng cách mở rộng Dialog
hoặc AlertDialog
?
có, cảm ơn sự giúp đỡ của bạn .i đã sử dụng hộp thoại Dialog = Hộp thoại mới (ngữ cảnh, R.style.CustomDialog), công việc rất tốt. nhưng tôi không thể viết Hộp thoại mở rộng, bạn có thể cho tôi một số Đoạn mã – pengwang
Tôi đã thêm một ví dụ về mở rộng Hộp thoại. –
là nó có thể thiết lập các nút tích cực và tiêu cực như chúng ta làm trong hộp thoại? i: e .setPositiveButton ("OK", DialogInterface.OnClickListener mới() {public void thoại onClick (DialogInterface, int whichButton) {// nút tích cực nhấp getActivityInstance() onOkClicked (GeneralDialogFragment.this);. } } –