Android Borderless Dialog

2019-01-10 15:06发布

I have created an AlertDialog using AlertDialog.Builder, but the Dialog border takes up too much space on the screen. How do I remove the border? I have tried using another Activity to emulate the dialog with a transparent background, but the dialog is used repeatedly, and creating a new Activity every time introduces a significant amount of lag.

The answer from here mentions that it can be found in the ApiDemos, but i can't seem to find it.

8条回答
叛逆
2楼-- · 2019-01-10 15:42

if you have 2 border you need to use a ContextThemeWrapper, which it will show only one border as you would like :)

ContextThemeWrapper wrapper = new ContextThemeWrapper(this, android.R.style.Theme_Holo);
final LayoutInflater inflater = (LayoutInflater) wrapper.getSystemService(LAYOUT_INFLATER_SERVICE);
AlertDialog.Builder builder = new AlertDialog.Builder(wrapper);
查看更多
Anthone
3楼-- · 2019-01-10 15:45

try this :D

 Dialog popUpView= new Dialog(this);
 popUpView.getWindow().setBackgroundDrawable(new ColorDrawable(0));
查看更多
登录 后发表回答