Custom Dialog without title and border

后端 未结 8 1128
终归单人心
终归单人心 2021-02-01 20:19

Based on the code here, http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog . I am successfully able to create a custom dialog with background and buttons ins

8条回答
  •  眼角桃花
    2021-02-01 21:06

    A Dialog cannot be created without a title. Further down in that tutorial it mentions:

    A dialog made with the base Dialog class must have a title. If you don't call setTitle(), then the space used for the title remains empty, but still visible. If you don't want a title at all, then you should create your custom dialog using the AlertDialog class. However, because an AlertDialog is created easiest with the AlertDialog.Builder class, you do not have access to the setContentView(int) method used above. Instead, you must use setView(View). This method accepts a View object, so you need to inflate the layout's root View object from XML.

    This answer solves both the title and the border problem using a custom style.

提交回复
热议问题