How does HTML Customize the dialog background? An article teaches you how to customize dialog!

Source: Internet
Author: User
This article is mainly about how to customize the background of dialog tags in html, there are some other style settings, code a lot, need their own understanding, then let us look at the HTML dialog customization of the article bar

Now let's start by implementing the first question of the article, how HTML customizes the background of the dialog tag:

Now many of the app's prompt dialog is very personality, but you still use the System dialog box style, is not feel very backward, today I will tell you how to customize their own dialog, after learning, you will be based on the theme of their own app, design the corresponding dialog style.

All right, now I'm going to talk about the general steps and principles of customizing dialog in a simple-style custom dialog.

First step: Set a Style theme for dialog (basically all with this theme) borderless full transparent background:

<!--custom Dialog background Full transparent borderless Theme-  <style name= "Mydialog" parent= "Android:style/theme.dialog" >  <!--background color and transparency--  <item name= "Android:windowbackground" > @android:color/transparent</item>  </style>

The dialog custom Background box is as follows:

<?xml version= "1.0" encoding= "Utf-8"?> <shape  xmlns:android= "http://schemas.android.com/apk/res/ Android ">      <solid android:color=" #ffffff "/>      <stroke          android:width=" 0.8DP "          android: Color= "#ffffff"/>      <!--rounded corners--      <corners android:radius= "6DP"/>  </shape>

The above is the simple process of customizing the dialog background in the app, if you want to know more, please topic.alibabacloud.com learn more.

Now let's talk about how to customize dialog:

A lot of things, look slowly

<style name= "Mydialog" parent= "Android:style/theme.dialog" >          <!--background color and transparency--          <item name= " Android:windowbackground "> @android:color/transparent</item>          <!--remove title--and          <item name= "Android:windownotitle" >true</item>          <!--remove Bezel--          <item name= "Android:windowframe" > @null </item>          <!--is on the activity--          <item name= "android:windowisfloating" >true </item>          <!--Blur--          <item name= "android:backgrounddimenabled" >false</item>  </style>

Step two : Set custom XML Interface for custom dialog, here I just demonstrate that you can use single, multi-Select, 3 buttons, 4 buttons and so on, format all kinds of custom XML, I define the title, message message, There is also a OK button and a Cancel button, as follows:

<?xml version= "1.0" encoding= "Utf-8"?> <relativelayout xmlns:android= "http://schemas.android.com/apk/res/ Android "Android:layout_width=" Match_parent "android:layout_height=" match_parent "android:background=" #11ff          FFFF "> <linearlayout android:layout_width=" 260dp "android:layout_height=" Wrap_content " Android:layout_centerinparent= "true" android:background= "@drawable/free_dialog_bg" Android:orientat ion= "vertical" > <textview android:id= "@+id/title" android:layout_width= "Wrap_co Ntent "android:layout_height=" wrap_content "android:layout_gravity=" Center "Android : layout_margin= "15DP" android:gravity= "center" android:text= "message Prompt" Android:textcolo              R= "#38ADFF" android:textsize= "16sp"/> <textview android:id= "@+id/message" Android:layout_width= "Wrap_content "android:layout_height=" wrap_content "android:layout_marginleft=" 20DP " android:layout_marginright= "20DP" android:text= "prompt message"/> <view android:layout_wi Dth= "Match_parent" android:layout_height= "1px" android:layout_margintop= "15DP" Android oid:background= "#E4E4E4"/> <linearlayout android:layout_width= "Match_parent" Android:lay out_height= "40DP" android:orientation= "horizontal" > <button android:id=                  "@+id/no" android:layout_width= "0DP" android:layout_height= "Match_parent"                   android:layout_marginleft= "10DP" android:layout_weight= "1" android:background= "@null"                  android:gravity= "Center" android:singleline= "true" android:text= "No" Android:Textcolor= "#7D7D7D" android:textsize= "16sp"/> <view android:layout                _width= "1px" android:layout_height= "match_parent" android:background= "#E4E4E4"/>                  <button android:id= "@+id/yes" android:layout_width= "0DP" android:layout_height= "Match_parent" android:layout_marginright= "10DP" Android:layout_w eight= "1" android:background= "@null" android:gravity= "center" android:s Ingleline= "true" android:text= "Yes" android:textcolor= "#38ADFF" Android : textsize= "16sp"/> </LinearLayout> </LinearLayout> </RelativeLayout>

The dialog custom Background box is as follows:

<?xml version= "1.0" encoding= "Utf-8"?> <shape  xmlns:android= "http://schemas.android.com/apk/res/ Android ">      <solid android:color=" #ffffff "/>      <stroke          android:width=" 0.8DP "          android: Color= "#ffffff"/>      <!--rounded corners--      <corners android:radius= "6DP"/>  </shape>

This is done although it is very long, but learning is a very slow process. Come on, 1.1.

Well, this article to this is also the end of the Welcome to watch, what questions can be asked below.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.