step:1:
style.xml
style.xml
<style name="Dialog" parent="android:Theme.Holo.Dialog"> <item name="android:alertDialogStyle">@style/CustomAlertDialogStyle</item> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:textColorPrimary">#FFFFFF</item> <item name="android:backgroundDimEnabled">false</item> <item name="android:textColor">#FFFFFF</item> <item name="android:textStyle">normal</item> <item name="android:textSize">12sp</item> </style> <style name="CustomAlertDialogStyle"> <item name="android:bottomBright">@android:color/transparent</item> <item name="android:bottomDark">@android:color/transparent</item> <item name="android:bottomMedium">@android:color/transparent</item> <item name="android:centerBright">@android:color/transparent</item> <item name="android:centerDark">@android:color/transparent</item> <item name="android:centerMedium">@android:color/transparent</item> <item name="android:fullBright">@android:color/transparent</item> <item name="android:fullDark">@android:color/transparent</item> <item name="android:topBright">@android:color/transparent</item> <item name="android:topDark">@android:color/transparent</item> </style>
step 2:
MainActivity.java
public class MainActivity extends AppCompatActivity {@Override
private
static
int
SPLASH_TIME_OUT =
3000
;
ProgressDialog progressDialog;protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);progressDialog=new ProgressDialog(ProfileActivity.this,R.style.Dialog); progressDialog.show();methed 2:
new
Handler().postDelayed(
new
Runnable() {
@Override
public
void
run() {
progressDialog.dismiss();
}
}, SPLASH_TIME_OUT);
///////////////////////////////////////////////////////////////}
}step 1:drawable/circular_progress_dialog.xmlstep 2:<rotate xmlns:android="http://schemas.android.com/apk/res/android"android:fromDegrees="270"android:toDegrees="270"> <shapeandroid:innerRadiusRatio="2.5"android:shape="ring"android:thickness="5dp"android:useLevel="true"><!-- this line fixes the issue for lollipop api 21 --> <gradientandroid:angle="0"android:endColor="#73052a"android:startColor="#d7bbc5"android:type="sweep"android:useLevel="false" /> </shape> </rotate>
layout/dialog.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"android:orientation="vertical"android:layout_width="match_parent"android:layout_height="match_parent"android:gravity="center"> <ProgressBarandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:indeterminateDrawable="@drawable/circular_progress_dialog" /> </LinearLayout>step 4:res/style<style name="Dialog" parent="android:Theme.Holo.Dialog"> <item name="android:alertDialogStyle">@style/CustomAlertDialogStyle</item> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:textColorPrimary">#FFFFFF</item> <item name="android:backgroundDimEnabled">false</item> <item name="android:textColor">#FFFFFF</item> <item name="android:textStyle">normal</item> <item name="android:textSize">12sp</item> </style> <style name="CustomAlertDialogStyle"> <item name="android:bottomBright">@android:color/transparent</item> <item name="android:bottomDark">@android:color/transparent</item> <item name="android:bottomMedium">@android:color/transparent</item> <item name="android:centerBright">@android:color/transparent</item> <item name="android:centerDark">@android:color/transparent</item> <item name="android:centerMedium">@android:color/transparent</item> <item name="android:fullBright">@android:color/transparent</item> <item name="android:fullDark">@android:color/transparent</item> <item name="android:topBright">@android:color/transparent</item> <item name="android:topDark">@android:color/transparent</item> </style>step 5:import android.app.Dialog; import android.app.ProgressDialog; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final Dialog dialog = new Dialog(MainActivity.this,R.style.Dialog); dialog.setContentView(R.layout.dialog); dialog.show(); }}