2 Jan 2015

Custom dialog with animation | Dialog effect Android

There are no any application available without alert massages,Generally we are using AlertDialog of android for Alert.

In this tutorial, you can achieve much more using dialog as per your desire like
-Set theme for dialog
-Set custom view in dialog
-Animations for dialog

Animation Effects :
Fadein, Slideleft, Slidetop, SlideBottom, Slideright, Fall, Newspager, Fliph, Flipv, RotateBottom, RotateLeft, Slit, Shake, Sidefill

For more visualization (See the Effect)

OUTPUT SCREEN :




Here is the implementation :

MainActivity :


import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import com.hb.lib.CustomDialogBuilder;
import com.hb.lib.Effectstype;

public class MainActivity extends Activity
{
       private Effectstype effect;

       @Override
       protected void onCreate(Bundle savedInstanceState)
       {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_main);
       }

       public void dialogShow(View v)
       {
              CustomDialogBuilder dialogBuilder=CustomDialogBuilder.getInstance(this);

              switch (v.getId())
              {
              case R.id.fadein:effect=Effectstype.Fadein;break;
              case R.id.slideright:effect=Effectstype.Slideright;break;
              case R.id.slideleft:effect=Effectstype.Slideleft;break;
              case R.id.slidetop:effect=Effectstype.Slidetop;break;
              case R.id.slideBottom:effect=Effectstype.SlideBottom;break;
              case R.id.newspager:effect=Effectstype.Newspager;break;
              case R.id.fall:effect=Effectstype.Fall;break;
              case R.id.sidefall:effect=Effectstype.Sidefill;break;
              case R.id.fliph:effect=Effectstype.Fliph;break;
              case R.id.flipv:effect=Effectstype.Flipv;break;
              case R.id.rotatebottom:effect=Effectstype.RotateBottom;break;
              case R.id.rotateleft:effect=Effectstype.RotateLeft;break;
              case R.id.slit:effect=Effectstype.Slit;break;
              case R.id.shake:effect=Effectstype.Shake;break;
              }

              dialogBuilder
              .withTitle("Alert Dialog")                           
              .withTitleColor("#FFFFFF")                           
              .withDividerColor("#cfdde7")                         
              .withMessage("This is a Dialog.")                    
              .withMessageColor("#FFFFFFFF")                           
              .withDialogColor("#264461")                              
              .withIcon(getResources().getDrawable(R.drawable.icon))
              .isCancelableOnTouchOutside(true)                         
              .withDuration(700)                                        
              .withEffect(effect)                                        
              .withButton1Text("OK")                                     
              .withButton2Text("Cancel")                                  
              .setCustomView(R.layout.custom_view,v.getContext()) 

              .setButton1Click(new View.OnClickListener()
              {
                     @Override
                     public void onClick(View v)
                     {
                           Toast.makeText(v.getContext(), "Press OK button", Toast.LENGTH_SHORT).show();
                     }
              })
              .setButton2Click(new View.OnClickListener()
              {
                     @Override
                     public void onClick(View v)
                     {
                           Toast.makeText(v.getContext(), "Press Cancel button", Toast.LENGTH_SHORT).show();
                     }
              })
              .show();

       }


}

Download Library & Sample :  DialogEffectSample

I will be happy if you will provide your feedback or follow this blog. Any suggestion and help will be appreciated.
Thank you :)

2 comments:

  1. Respecting the time and exertion you put into your site and point by point data you offer!..
    Custom Animated Logo

    ReplyDelete