Android uses the dialog style pop-up box activity_android

Source: Internet
Author: User

The activity that needs to use the dialog style pop-up box is often encountered in Android, first of all, we might first think of setting the android:layout_height= "Wrap_content" attribute in the XML layout file. Let the activity be highly adaptive, obviously not yet, we also need to set a custom style for its dialogactivity  

<style name= "Dialogstyle" >
  <!--Setting dialog background--> <item name=
  "Android:windowbackground" >@ Android:color/transparent</item>
  <!--Set dialog windowframe box for no-->
  <item name= "Android: Windowframe "> @null </item>
  <!--set Untitled-->
  <item name=" Android:windownotitle ">true< /item>
  <!--emerging from activity-->
  <item name= "android:windowisfloating" >true</item>
  <!--translucent-->
  <item name= "android:windowistranslucent" >true</item>
  <!-- Set the window content to not overwrite-->
  <item name= "Android:windowcontentoverlay" > @null </item>
  <!--set animation, Here we use the animation.dialog-->
  <item name= "Android:windowanimationstyle" > @android that let it inherit the system: style/ Animation.dialog</item>
  <!--background fuzzy display-->
  <item name= "android:backgrounddimenabled" > True</item>
 </style>

Then set the dialogactivity style for our custom androidmanifest.xml in the Dialogstyle

The following are the code for the layout

<?xml version= "1.0" encoding= "Utf-8"?> <linearlayout xmlns:android= "http://schemas.android.com/apk/res/" Android "Android:layout_width=" Match_parent "android:layout_height=" wrap_content "android:background=" @color White "android:orientation=" vertical "> <linearlayout android:layout_width=" match_parent "Android:layout_heig ht= "65DP" android:orientation= "horizontal" android:paddingleft= "@dimen/acitvity_margin" android:paddingright= "@ Dimen/acitvity_margin "> <linearlayout android:layout_width=" 0dp "android:layout_height=" Match_parent "an
    droid:layout_weight= "1" android:orientation= "horizontal" > <textview android:layout_width= "wrap_content" android:layout_height= "match_parent" android:gravity= "center" android:text= "Work Time:" Android:textcolor= "@colo R/grey "android:textsize=" @dimen/size_text_medium "/> <button android:id=" @+id/tv_signin_time "Andro Id:layout_width= "Wrap_content" android:layout_height= "Match_parent" android:background= "@color/white" android:gravity= "center" android:text= "9:00" Andr Oid:textcolor= "@color/grey" android:textsize= "@dimen/size_text_medium"/> </LinearLayout> <linearlayo UT android:layout_width= "0DP" android:layout_height= "Match_parent" android:layout_weight= "1" Android:orientati
    on= "Horizontal" > <textview android:layout_width= "wrap_content" android:layout_height= "Match_parent" android:gravity= "Center" android:text= "Work Time:" android:textcolor= "@color/grey" android:textsize= "@dimen/size_te Xt_medium "/> <button android:id= @+id/tv_signout_time" android:layout_width= "Wrap_content" Android:
    layout_height= "Match_parent" android:background= "@color/white" android:gravity= "center" android:text= "18:00" Android:textcolor= "@color/grey" android:textsize= "@dimen/size_text_medium"/> </LinearLayout> </line Arlayout> <relatIvelayout android:layout_width= "match_parent" android:layout_height= "65DP" android:paddingleft= "@dimen/acitvity_ Margin "android:paddingright=" @dimen/acitvity_margin "> <textview android:layout_width=" wrap_content "Andr oid:layout_height= "Match_parent" android:layout_alignparentleft= "true" android:gravity= "center" android:text= "company position Place: "android:textcolor=" @color/grey "android:textsize=" @dimen/size_text_medium "/> <edittext" @+id/et_address "android:layout_width=" wrap_content "android:layout_height=" Match_parent "Android:layout_marginLe" ft= "2DP" android:layout_torightof= "@+id/tv_address" android:background= "@color/white" android:hint= "Please enter company location" a Ndroid:singleline= "true" android:textsize= "@dimen/size_text_small"/> <textview android:id= "@+id/tv_locatio N "android:layout_width=" wrap_content "android:layout_height=" Wrap_content "android:layout_alignparentright=" true "Android:layout_centerinParent= "true" android:gravity= "center" android:padding= "5DP" android:text= "relocate android:textcolor=" @color/blu E "android:textsize=" @dimen/size_text_medium "/> </RelativeLayout> <relativelayout Android:layout_widt H= "Match_parent" android:layout_height= "65DP" android:paddingleft= "@dimen/acitvity_margin" android:paddingright= " 
   @dimen/acitvity_margin "> <textview android:layout_width=" wrap_content "android:layout_height=" Match_parent " Android:layout_alignparentleft= "true" android:gravity= "center android:text=" Settings administrator: "Android:textcolor=" @colo R/grey "android:textsize=" @dimen/size_text_medium "/> <imageview android:layout_width=" Wrap_content "and roid:layout_height= "Match_parent" android:layout_alignparentright= "true" android:gravity= "center" android:src= "@m" 

 Ipmap/icon_toright "/> </RelativeLayout> </LinearLayout>

Let's take a look at the effect chart, is that what we want?

SOURCE Download: http://xiazai.jb51.net/201609/yuanma/DialogActivity (jb51.net). rar

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

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.