Thursday, 28 December 2017

Animations

Animation 1 :

res/anim/

sample.xml

<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
  android:interpolator="@android:anim/accelerate_decelerate_interpolator"
  android:duration="300"
  android:fillAfter="true"
  android:fromXScale="0.0"
  android:fromYScale="0.0"
  android:toXScale="1.0"
  android:toYScale="1.0" />

Animation 2 :

res/anim/

fad_in.xml

<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:fillAfter="true" >

    <alpha
        android:duration="1000"
        android:fromAlpha="0.0"
        android:interpolator="@android:anim/accelerate_interpolator"
        android:toAlpha="1.0" />

</set>

Animation 3 :

res/anim/

fad_out.xml

<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:fillAfter="true" >

    <alpha
        android:duration="1000"
        android:fromAlpha="1.0"
        android:interpolator="@android:anim/accelerate_interpolator"
        android:toAlpha="0.0" />

</set>

Animation 4 :

res/anim/

blink.xml

<set xmlns:android="http://schemas.android.com/apk/res/android">
    <alpha android:fromAlpha="0.0"
        android:toAlpha="1.0"
        android:interpolator="@android:anim/accelerate_interpolator"
        android:duration="600"
        android:repeatMode="reverse"
        android:repeatCount="infinite"/>
</set>

Animation 5 :

res/anim/

zoom_in.xml

<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:fillAfter="true" >

    <scale
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:duration="1000"
        android:fromXScale="1"
        android:fromYScale="1"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toXScale="3"
        android:toYScale="3" >
    </scale>

</set>

Animation 6 :

res/anim/

zoom_out.xml

<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:fillAfter="true" >

    <scale
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:duration="1000"
        android:fromXScale="1.0"
        android:fromYScale="1.0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toXScale="0.5"
        android:toYScale="0.5" >
    </scale>

</set>

Animation 7 :

res/anim/

rotate.xml

<set xmlns:android="http://schemas.android.com/apk/res/android">
    <rotate android:fromDegrees="0"
        android:toDegrees="360"
        android:pivotX="50%"
        android:pivotY="50%"
        android:duration="600"
        android:repeatMode="restart"
        android:repeatCount="infinite"
        android:interpolator="@android:anim/cycle_interpolator"/>

</set>

Animation 8 :

res/anim/

moov.xml

<set
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/linear_interpolator"
    android:fillAfter="true">

   <translate
        android:fromXDelta="0%p"
        android:toXDelta="75%p"
        android:duration="800" />
</set>

Animation 9 :

res/anim/

slide_up.xml

<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:fillAfter="true" >

    <scale
        android:duration="500"
        android:fromXScale="1.0"
        android:fromYScale="1.0"
        android:interpolator="@android:anim/linear_interpolator"
        android:toXScale="1.0"
        android:toYScale="0.0" />

</set>


Animation 10 :

res/anim/

slide_down.xml

<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:fillAfter="true">

    <scale
        android:duration="500"
        android:fromXScale="1.0"
        android:fromYScale="0.0"
        android:toXScale="1.0"
        android:toYScale="1.0" />

</set>

Animation 11 :

res/anim/

bouncexml

<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:fillAfter="true"
    android:interpolator="@android:anim/bounce_interpolator">

    <scale
        android:duration="500"
        android:fromXScale="1.0"
        android:fromYScale="0.0"
        android:toXScale="1.0"
        android:toYScale="1.0" />

</set>

Animation 12 :

res/anim/

sequential.xml

<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:fillAfter="true"
    android:interpolator="@android:anim/linear_interpolator" >

  
    <!-- Move -->
    <translate
        android:duration="800"
        android:fillAfter="true"
        android:fromXDelta="0%p"
        android:startOffset="300"
        android:toXDelta="75%p" />
    <translate
        android:duration="800"
        android:fillAfter="true"
        android:fromYDelta="0%p"
        android:startOffset="1100"
        android:toYDelta="70%p" />
    <translate
        android:duration="800"
        android:fillAfter="true"
        android:fromXDelta="0%p"
        android:startOffset="1900"
        android:toXDelta="-75%p" />
    <translate
        android:duration="800"
        android:fillAfter="true"
        android:fromYDelta="0%p"
        android:startOffset="2700"
        android:toYDelta="-70%p" />

    <!-- Rotate 360 degrees -->
    <rotate
        android:duration="1000"
        android:fromDegrees="0"
        android:interpolator="@android:anim/cycle_interpolator"
        android:pivotX="50%"
        android:pivotY="50%"
        android:startOffset="3800"
        android:repeatCount="infinite"
        android:repeatMode="restart"
        android:toDegrees="360" />

</set>

Animation 13 :

res/anim/

together.xml

<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:fillAfter="true"
    android:interpolator="@android:anim/linear_interpolator" >

    
    <!-- Move -->
    <scale
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:duration="4000"
        android:fromXScale="1"
        android:fromYScale="1"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toXScale="4"
        android:toYScale="4" >
    </scale>

    <!-- Rotate 180 degrees -->
    <rotate
        android:duration="500"
        android:fromDegrees="0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:repeatCount="infinite"
        android:repeatMode="restart"
        android:toDegrees="360" />

</set>


ImageView Shape


Step 1:

You have to do first :


compile 'com.github.siyamed:android-shape-imageview:0.9.+@aar'


Shape 1:   Bubble ImageView
<com.github.siyamed.shapeimageview.BubbleImageView
    android:layout_width="200dp"
    android:layout_height="200dp"
    android:src="@drawable/neo"
    app:siArrowPosition="right"
    app:siSquare="false"/>


Shape 2:   Rounded ImageView
<com.github.siyamed.shapeimageview.RoundedImageView
    android:layout_width="200dp"
    android:layout_height="200dp"    android:src="@drawable/neo"
    app:siRadius="6dp"
    app:siBorderWidth="6dp"
    app:siBorderColor="@color/darkgray"
    app:siSquare="false"/>


Shape 3:   Circle ImageView
<com.github.siyamed.shapeimageview.CircularImageView
    android:layout_width="200dp"    android:layout_height="200dp"    android:src="@drawable/neo"
    app:siBorderWidth="6dp"
    app:siBorderColor="@color/darkgray"/>


Shape 4:   Diamond ImageView
<com.github.siyamed.shapeimageview.DiamondImageView
    android:layout_width="200dp"    android:layout_height="200dp"    android:layout_margin="8dp"
    android:src="@drawable/neo"
    app:siBorderWidth="8dp"
    app:siBorderColor="@color/darkgray"/>


Shape 5:   Pentagon ImageView
<com.github.siyamed.shapeimageview.PentagonImageView
android:layout_width="200dp" android:layout_height="200dp" android:src="@drawable/neo" app:siArrowPosition="right" app:siSquare="false"/>


Shape 6:   Xexagon ImageView
<com.github.siyamed.shapeimageview.HexagonImageView
    android:layout_width="200dp"    android:layout_height="200dp"    android:src="@drawable/neo"
    app:siArrowPosition="right"
    app:siSquare="false"/>


Shape 7:   Octogon ImageView
<com.github.siyamed.shapeimageview.OctogonImageView
    android:layout_width="200dp"    android:layout_height="200dp"    android:src="@drawable/neo"
    app:siArrowPosition="right"
    app:siSquare="false"/>


Shape 8:   Star ImageView
<com.github.siyamed.shapeimageview.StarImageView
    android:layout_width="200dp"    android:layout_height="200dp"    android:src="@drawable/neo"
    app:siArrowPosition="right"
    app:siSquare="false"/>


Shape 9:  Heart  ImageView
<com.github.siyamed.shapeimageview.HeartImageView
    android:layout_width="200dp"    android:layout_height="200dp"    android:src="@drawable/neo"
    app:siArrowPosition="right"
    app:siSquare="false"/>


Shape 10:   Star ImageView
<com.github.siyamed.shapeimageview.mask.PorterShapeImageView
    android:layout_width="200dp"    android:layout_height="200dp"    app:siShape="@drawable/star"
    android:src="@drawable/neo"
    app:siSquare="false"/>
Shape 11:   PorterShape ImageView
<com.github.siyamed.shapeimageview.mask.PorterShapeImageView
    android:layout_width="200dp"    android:layout_height="200dp"    app:siShape="@drawable/shape_rounded_rectangle"
    android:src="@drawable/neo"
    app:siSquare="false"/>
res/drawable/ shape_rounded_rectangle.xml
<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">
    <corners
        android:topLeftRadius="18dp"
        android:topRightRadius="18dp"
        android:bottomLeftRadius="18dp"
        android:bottomRightRadius="18dp" />
    <solid android:color="@color/black" />
</shape>

Thursday, 9 November 2017

Animation Button

Step 1:

res/layout/Animation.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.evgenii.sixbouncingbuttons.MainActivity">

    <Button
        android:id="@+id/button_animate"
        android:layout_width="100dp"
        android:layout_height="40dp"
        android:onClick="didTapButton"
        android:background="#FFA400" />

</android.support.constraint.ConstraintLayout>
Step 2:
res/anim/animation.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >

    <scale
        android:duration="2000"
        android:fromXScale="0.3"
        android:toXScale="1.0"
        android:fromYScale="0.3"
        android:toYScale="1.0"
        android:pivotX="50%"
        android:pivotY="50%" />
</set>
step 3:
following method use in your activity
method 1:
public void didTapButton(View view) {
    Button button = (Button)findViewById(R.id.button);
    final Animation myAnim = AnimationUtils.loadAnimation(this, R.anim.bounce);
    button.startAnimation(myAnim);
}
method 2:
class MyAnimation implements android.view.animation.Interpolator {
    private double mAmplitude = 1;
    private double mFrequency = 10;

    MyAnimation (double amplitude, double frequency) {
        mAmplitude = amplitude;
        mFrequency = frequency;
    }

    public float getInterpolation(float time) {
        return (float) (-1 * Math.pow(Math.E, -time/ mAmplitude) *
                Math.cos(mFrequency * time) + 1);
    }
}
method 3:
public void didTapButton(View view) {
    Button button = (Button)findViewById(R.id.button);
    final Animation myAnim = AnimationUtils.loadAnimation(this, R.anim.bounce);

    // Use bounce interpolator with amplitude 0.2 and frequency 20
    MyBounceInterpolator interpolator = new MyBounceInterpolator(0.2, 20);
    myAnim.setInterpolator(interpolator);

    button.startAnimation(myAnim);
}

Friday, 3 November 2017

Custom Datepicker Dialog Differend Style


step 1:
activity_main.xml

<RelativeLayout   
 xmlns:android="http://schemas.android.com/apk/res/android"    
xmlns:tools="http://schemas.android.com/tools"    
android:id="@+id/rl"    
android:layout_width="match_parent"    
android:layout_height="match_parent"    
android:padding="10dp"    
tools:context=".MainActivity"    
android:background="#e6eae8"    >
    <Button        
android:id="@+id/btn"        
android:layout_width="wrap_content"       
android:layout_height="wrap_content"        
android:text="Set Date"        />
</RelativeLayout>

step 2:
MainActivity.java

import android.app.DatePickerDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.app.AlertDialog;
import android.app.Dialog;
import android.widget.RelativeLayout;
import android.app.DialogFragment;
import java.util.Calendar;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    Button btnDatePicker, btnTimePicker;
    EditText txtDate, txtTime;
    private int mYear, mMonth, mDay, mHour, mMinute,mAMPM;

    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final RelativeLayout rl = (RelativeLayout) findViewById(R.id.rl);
        Button btn = (Button) findViewById(R.id.btn);

        btn.setOnClickListener(new View.OnClickListener() {
            @Override           
          public void onClick(View v) {
                // Initialize a new date picker dialog fragment               
        DialogFragment dFragment = new DatePickerFragment();

                // Show the date picker dialog fragment        
        dFragment.show(getFragmentManager(), "Date Picker");
            }
        });
    }

    @Override    public void onClick(View v) {

    }


    public static class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener{

        @Override        public Dialog onCreateDialog(Bundle savedInstanceState){
            final Calendar calendar = Calendar.getInstance();
            int year = calendar.get(Calendar.YEAR);
            int month = calendar.get(Calendar.MONTH);
            int day = calendar.get(Calendar.DAY_OF_MONTH);
            /*                Create a DatePickerDialog using Theme.
                    DatePickerDialog(Context context, int theme, 
                     DatePickerDialog.OnDateSetListener listener,                        
                            int year, int monthOfYear, int dayOfMonth)             */

            // DatePickerDialog THEME_DEVICE_DEFAULT_LIGHT            
                  DatePickerDialog dpd = new DatePickerDialog(getActivity(),
                  AlertDialog.THEME_DEVICE_DEFAULT_LIGHT,this,year,month,day);

            // DatePickerDialog THEME_DEVICE_DEFAULT_DARK            
                    DatePickerDialog dpd2 = new DatePickerDialog(getActivity(),
                    AlertDialog.THEME_DEVICE_DEFAULT_DARK,this,year,month,day);

            // DatePickerDialog THEME_HOLO_LIGHT
                    DatePickerDialog dpd3 = new DatePickerDialog(getActivity(),
                    AlertDialog.THEME_HOLO_LIGHT,this,year,month,day);

            // DatePickerDialog THEME_HOLO_DARK 
                    DatePickerDialog dpd4 = new DatePickerDialog(getActivity(),
                    AlertDialog.THEME_HOLO_DARK,this,year,month,day);

            // DatePickerDialog THEME_TRADITIONAL
                    DatePickerDialog dpd5 = new DatePickerDialog(getActivity(),
                    AlertDialog.THEME_TRADITIONAL,this,year,month,day);

            // Return the DatePickerDialog            
                   return  dpd5;
        }

        public void onDateSet(DatePicker view, int year, int month, int day){
            // Do something with the chosen date        }
    }
}

HOW TO CREATE CIRCLE IMAGE VIEW

Step 1: implementation 'de.hdodenhof:circleimageview:3.0.0' Step 2: <de.hdodenhof.circleimageview.CircleImageView xmlns:ap...