The example in this article describes an activity that the Android implementation can use to customize the transparent dialog style. Share to everyone for your reference, specific as follows:
Sometimes you need a dialog box, but the content in the dialog box has more control and control over its lifecycle, and you can use a dialog-style activity to apply your project, so that the activity has a dialog box that can be added to the androidmanifest Theme features of Android:style/theme.dialog
For example this:
<activity android:name= "mydialogactivity"
android:theme= "@android: Style/theme.dialog" >
</ Activity>
If you feel that the above is not enough to meet your needs to achieve translucent, rounded corners, you may wish to try the custom dialog box style
First of all
The first step : Prepare to do a good job. 9 pictures
Loading_bg.9.png
Step two : Custom style Creates a Styles.xml file in your project values folder
Then add a style named Mydialogstyle to the styles file
<style name= "Mydialogstyle" >
<item name= "Android:windowbackground" > @android: Color/transparent </item>
<item name= "Android:windowframe" > @null </item>
<item name= "Android: Windownotitle ">true</item>
<item name=" android:windowisfloating ">true</item>
< Item Name= "Android:windowistranslucent" >true</item>
<item name= "Android:windowcontentoverlay" > @null </item>
<item name= "Android:windowanimationstyle" > @android: style/animation.dialog</ item>
<item name= "android:backgrounddimenabled" >true</item>
</style>
Step three : Dialog layout adds a layout file to the Layout folder Activity_main.xml
<relativelayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http:// Schemas.android.com/tools "android:layout_width=" match_parent "android:layout_height=" Match_parent "> <
Relativelayout android:layout_width= "180DP" android:layout_height= "180DP" android:layout_centerinparent= "true" android:background= "@drawable/loading_bg" > <linearlayout android:layout_width= "fill_parent" an
droid:layout_height= "Fill_parent" android:layout_alignparentleft= "true" android:layout_alignparenttop= "true" android:gravity= "center" android:orientation= "vertical" > <progressbar android:id= "@+id/pro" GressBar1 "style="? Android:attr/progressbarstylelarge "Android:layout_width=" Wrap_content "Android : layout_height= "wrap_content" android:layout_gravity= "Center_horizontal"/> <textview android: Layout_width= "Wrap_content" android:layout_height= "Wrap_content" android:layout_margintop= "10DP" android:text= "Logging on" android:textcolor= "#fff"
Android:textsize= "20sp"/> </LinearLayout> </RelativeLayout> </RelativeLayout>
Create Dialogactivity Class
public class Dialogactivity extends activity
{
@Override
protected void OnCreate (Bundle Savedinstancestate)
{
super.oncreate (savedinstancestate);
Setcontentview (r.layout.activity_main);
Here you can do some waiting operation, I here in 8 seconds after the toast agent waiting for the operation of the
New Handler (). postdelayed (New Runnable () {
@Override public
void Run () {
DialogActivity.this.finish ();
Toast.maketext (Getapplicationcontext (), "Login Successful", Toast.length_short). Show ();
}
, 8000);
}
Step Fourth : Register the dialogactivity in the manifest file and use the custom Mydialogstyle style above
<activity
android:name= "loadingactivity"
android:theme= "@style/mydialogstyle"/>
Step Fifth : Run the project and view the effect chart
Finish the call.
More interested readers of Android-related content can view the site: "Summary of the activity operations of Android Programming", "Summary of the usage of Android controls", "Overview of the Android View View Tips", "a summary of the Android file Operation Tips", "Android Operation SQLite Database Skills Summary", "Android operation JSON format Data Skills summary", "Android Database Operation skills Summary", "Android programming development of SD card Operation Summary", "Android Development introduction and Advanced Course" A summary of Android resource operations tips
I hope this article will help you with the Android program.