
hiiii everyone in this tutorial I am sharing how to used animation with the button. if you want to create a nice App UI to used Animation. It’s very easy to use. just follow the simple step. Android animation with buttons. Android button UI.
Step 1: First one to Start Android Studio
Step 2 : Seconds step to Create a New Project Project ClickOn ==> File ==> NEW ==> New Project
Step 3: After create on your project open your java file and XML file and you can just copy the code and paste on your file and run your project.
Step 4: Create a bounce drawable XML file res==>drawable==>bounce.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 5: Open Your activity_home.xml and Create a button design with CardView.
<android.support.v7.widget.CardView
android:id="@+id/FreeBtn"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_margin="10dp"
card_view:cardBackgroundColor="@color/white"
card_view:cardCornerRadius="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal">
<View
android:layout_width="10dp"
android:layout_height="match_parent"
android:background="@color/colorPrimary"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:layout_weight="1"
android:textStyle="bold"
android:gravity="center_vertical"
android:textColor="@color/black"
android:textAppearance="?android:textAppearanceLarge"
android:text="Online Free"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tint="@color/colorPrimary"
android:src="@drawable/ic_right"/>
</LinearLayout>
</android.support.v7.widget.CardView>
Step 6: Open Your home.java Class and add this code.
public class Home extends AppCompatActivity {
CardView VisitBtn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
final Animation myAnim = AnimationUtils.loadAnimation(this, R.anim.bounce);
VisitBtn=(CardView)findViewById(R.id.FreeBtn);
VisitBtn.startAnimation(myAnim);
}
}




