Detailed explanation of how Android customizes the upgrade dialog box

preface

This article mainly introduces the relevant contents of the Android custom upgrade dialog box for your reference and learning. Let's take a look at the detailed introduction.

The results are as follows

In fact, this is just a dialog fragment. The focus is only on the design of the interface

To create such a dialogfragment, you need to customize a view, and then pass the view into the dialog

First define the layout. A textview is used for the title, a textview is used to upgrade the content description, an ImageView and a button to confirm the upgrade

Among them, the button needs to use a custom style

Create a subclass of dialogfragment

And then call Dialog in MainActivity.

Here's the interface

You can see that there is a large blank area in the dialog, which seems a little vain

Here, you can choose to specify the proportion of dialog in the screen width in the OnStart () method of versiondialogfragment

Set here to occupy 70% of the screen width

The renderings are shown below

At this time, the four corners of the dialog are straight. Here, change it to fillet

Create a new root.xml file in the drawable folder as the background of the root layout of the layout used by dialog

Then modify the OnStart () method to set the transparent background color for the dialog window

In this way, the overall effect is completed

Sample code download: Android custom upgrade dialog box is provided here

summary

The above is the whole content of this article. I hope the content of this article can bring some help to the study or work of Android developers. If you have any questions, you can leave a message. Thank you for your support for programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>