Android Dialog - Rounded Corners and Transparency

后端 未结 11 553
日久生厌
日久生厌 2020-12-09 16:12

I\'m trying to make a custom android dialog with rounded corners. My current attempts have given me this result.

\"

11条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-09 16:44

    The only solution I have found is here. Use Dialog instead of AlertDialog and set transparent background:
    dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
    Therefore you can't use the builder. But you can use new Dialog() also in onCreateDialog callback of DialogFragment if you follow to best guidelines.

    This works also for Gingerbread.

    Besides the layered drawable can be simplified to one shape with xml element for the border.

提交回复
热议问题