Created
June 6, 2016 10:46
-
-
Save VijayMakwana/97a8def27702067032b7c899f0dd6a79 to your computer and use it in GitHub Desktop.
Custom alert dialog with image including animation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<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" | |
android:paddingBottom="@dimen/activity_vertical_margin" | |
android:paddingLeft="@dimen/activity_horizontal_margin" | |
android:paddingRight="@dimen/activity_horizontal_margin" | |
android:paddingTop="@dimen/activity_vertical_margin" | |
tools:context="com.reversebits.tapanhp.customalertproteen.MainActivity"> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="Hello World!" /> | |
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.reversebits.tapanhp.customalertproteen; | |
import android.app.Dialog; | |
import android.graphics.Color; | |
import android.graphics.drawable.ColorDrawable; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.view.Window; | |
import android.view.animation.Animation; | |
import android.view.animation.LinearInterpolator; | |
import android.view.animation.RotateAnimation; | |
import android.widget.ImageView; | |
public class CustomAlertDia extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
//crated new alert dialog | |
Dialog alertDialog = new Dialog(this); | |
alertDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); | |
alertDialog.setContentView(R.layout.progress_dia); | |
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); //transperent background | |
ImageView hero = (ImageView)alertDialog.findViewById(R.id.iv_progress); | |
//setup rotate background effect | |
RotateAnimation ro = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); | |
ro.setDuration(1500); | |
ro.setRepeatCount(Animation.INFINITE); | |
ro.setInterpolator(new LinearInterpolator()); | |
hero.setAnimation(ro); | |
alertDialog.show(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:orientation="vertical" android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<ImageView | |
android:layout_width="160dp" | |
android:layout_height="160dp" | |
android:layout_centerInParent="true" | |
android:src="@drawable/icon_progressbar" | |
android:id="@+id/iv_progress"/> | |
<ImageView | |
android:layout_width="155dp" | |
android:layout_height="155dp" | |
android:layout_centerInParent="true" | |
android:src="@drawable/icon_progress_hero" | |
android:id="@+id/iv_progress_hero"/> | |
</RelativeLayout> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment