Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to customize the Dialog effect of pop-up box by Android

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

Today, I would like to share with you the relevant knowledge of how Android defines the Dialog effect of the pop-up frame. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look.

The specific effects are as follows

1.dialog_delete.xml

two。 Set the background border and create a dialog_white_back.xml in drawable

The color and fillet can be modified according to your own needs.

3. The background border of the button to create a round_gray.xml in drawable

The color and fillet can be modified according to your own needs.

4. Add to the Style file

True @ null true @ android:color/transparent true @ null @ color/clear @ color/clear

5.Java code section

/ * Delete AlertDialog * / public void DeleteDialog () {/ / layout, id View view = LayoutInflater.from (getActivity ()) .propagate (R.layout.dialog_delete, null); ImageView delete_close_id = view.findViewById (R.id.delete_close_id); TextView delete_device_id = view.findViewById (R.id.delete_device_id) TextView delete_cancle_id = view.findViewById (R.id.delete_cancle_id); TextView delete_sure_id = view.findViewById (R.id.delete_sure_id); / / display style final Dialog dialog = new Dialog (getActivity (), R.style.BottomDialog); dialog.setContentView (view); dialog.getWindow (). SetBackgroundDrawableResource (android.R.color.transparent); DisplayMetrics dm = getResources (). GetDisplayMetrics () Int displayWidth = dm.widthPixels; int displayHeight = dm.heightPixels; android.view.WindowManager.LayoutParams p = dialog.getWindow (). GetAttributes (); / / get the current parameter value of the dialog box p.width = (int) (displayWidth * 0.8); / / set the width to 0.5 / / dialog.setCanceledOnTouchOutside (false) of the screen / / Click on screen Dialog does not disappear dialog.getWindow () .setAttributes (p); / / set effective dialog.show (); / / Click to close delete_close_id.setOnClickListener (new View.OnClickListener () {@ Override public void onClick (View v) {dialog.dismiss ();}})) / / Click OK to delete delete_sure_id.setOnClickListener (new View.OnClickListener () {@ Override public void onClick (View v) {dialog.dismiss ();}})) / / Click to cancel the deletion of delete_cancle_id.setOnClickListener (new View.OnClickListener () {@ Override public void onClick (View v) {dialog.dismiss ();}});} above is all the content of the article "how to customize the Dialog effect of Android pop-up box". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report