Get the App
SLTechnology News&Howtos  ›  Development  › 

How to remove the White Border Code from Dialog in Android

Shulou Source: shulou.com Published: 2022-06-03 05:35:08 10月05日 Update

This article will explain in detail how to remove the white border code of Dialog in Android. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

Using the style file, create a new styles.xml file in the values directory and write the following code:

@ null

True

False

True

@ android:color/black

@ null

False

When calling, the API class of AlerDialog is used, and the Dialog API is written as follows:

Dialog dialog = new Dialog (SetActivity.this, R.style.dialog)

Dialog.setContentView (R.layout.test)

Dialog.show ()

Let's take a look at the source file of Dialog, where the constructor is as follows:

Public Dialog (Context context, int theme) {

MContext = new ContextThemeWrapper (

Context, theme = = 0? Com.android.internal.R.style.Theme_Dialog: theme)

MWindowManager = (WindowManager) context.getSystemService ("window")

Window w = PolicyManager.makeNewWindow (mContext)

MWindow = w

W.setCallback (this)

W.setWindowManager (mWindowManager, null, null)

W.setGravity (Gravity.CENTER)

MUiThread = Thread.currentThread ()

MDismissCancelHandler = new DismissCancelHandler (this)

}

In this we can see that Android uses the default constructor to set the style for Dialog, if there is no style for it, that is, the default loads the pre-written style file, Dialog consists of multiple 9.png images, most of which are 9.png pictures with borders, so that is why the above style file should remove its background. This thing has been messing with me for a long time. I hope it will help you.

Comparison of the effect before and after

Before setting:

After setting up:

On Android Dialog how to remove the white border code is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Files styles code borders white content functions pictures interfaces articles more knowledge articles help yes above things multiple mostly just Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology MySQL Shulou Tech Info Microsoft Shulou Information