Quick Setup - Stevexls/BounceView GitHub Wiki
Assume you have added lib dependency.
Step 1. Edit activity layout xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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=".MainActivity">
<ImageView
android:id="@+id/iv_pub"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:src="@drawable/ic_nav_add_normal" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/background"
android:layout_above="@id/iv_pub"/>
<com.bounceviewlib.BounceView
android:id="@+id/bounce"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<ImageView
android:id="@+id/bounce_background"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<RelativeLayout
android:id="@+id/bounce_content"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerHorizontal="true">
<LinearLayout
android:id="@+id/ll_folder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="100dp"
android:orientation="vertical">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center_horizontal"
android:scaleType="centerCrop"
android:src="@mipmap/folder" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:text="folder"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll_note"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="40dp"
android:layout_marginBottom="100dp"
android:layout_toRightOf="@id/ll_folder"
android:orientation="vertical">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center_horizontal"
android:scaleType="centerCrop"
android:src="@mipmap/note" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:text="note"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll_picture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="40dp"
android:layout_marginBottom="100dp"
android:layout_toRightOf="@id/ll_note"
android:orientation="vertical">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center_horizontal"
android:scaleType="centerCrop"
android:src="@mipmap/picture" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:text="picture"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll_wallet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="40dp"
android:layout_marginBottom="100dp"
android:layout_toRightOf="@id/ll_picture"
android:orientation="vertical">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center_horizontal"
android:scaleType="centerCrop"
android:src="@mipmap/wallet" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:text="wallet"
android:textSize="15sp" />
</LinearLayout>
</RelativeLayout>
<ImageView
android:id="@+id/bounce_pub"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:src="@drawable/ic_nav_add_normal" />
</com.bounceviewlib.BounceView>
</RelativeLayout>
Note:
- popup background (ImageView or others)
android:id="@+id/bounce_background"
- popup content ViewGroup
android:id="@+id/bounce_content"
- popup
android:id="@id/swipe_load_more_footer"
Step 2. Write java code
ivPub = findViewById(R.id.iv_pub);
ivPub.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// begin pop up animation
bounceView.startAnim();
}
});
bounceView = findViewById(R.id.bounce);
// Style.ROUND, Style.ALPHA, Style.TRANS, Style.NONE
bounceView.setBgAnimStyle(BounceView.Style.ROUND);
// bounceView.setBounceBgColor(getResources().getColor(R.color.colorAccent));
// bounceView.setBounceBgDrawable(drawable);
// bounceView.setBgAnimDuration(300); // default 300ms, or you can set another
// bounceView.setContentAnimDuration(400); // default 300ms
// bounceView.setPubAnimDuration(400); // default 300ms
bounceView.setBounceBgBlur(true); // blur
bounceView.setOnPubCloseListener(new BounceView.OnPubCloseListener() {
@Override
public void onPubClose() {
// do something
Log.i(TAG, "animation end");
}
});
bounceView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// end animation
bounceView.closeAnim();
}
});
All done. Very simple, isn't it?