Skip to content

Instantly share code, notes, and snippets.

@rezaiyan
rezaiyan / ViewTransaction
Last active September 18, 2017 10:22
View transaction
//Start View
Intent intent = new Intent(context, SearchActivity.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ActivityOptions options = ActivityOptions.
makeSceneTransitionAnimation(getActivity(), v, "transition");
startActivity(intent, options.toBundle());
}else
startActivity(intent);
//End View
@rezaiyan
rezaiyan / CustomToast
Created September 18, 2017 10:02
Custom Toast
public class CustomToast {
public static void showToast(Context context,String message) {
Toast toast = Toast.makeText(context, message, Toast.LENGTH_SHORT);
toast.setGravity(Gravity.BOTTOM, toast.getXOffset() / 3, toast.getYOffset() / 3);
TextView textView = new TextView(context);
textView.setBackgroundColor(Color.DKGRAY);
textView.setTextColor(Color.WHITE);
textView.setTypeface(FontManager.Iransens(context));
@rezaiyan
rezaiyan / HidingScrollListener
Created September 18, 2017 10:01
hide show view with scrolling recyclerview
package com.daimajia.slider.library;
import android.support.v7.widget.RecyclerView;
/**
* Created by Rezaiyan on 9/18/2017.
*/
public abstract class HidingScrollListener extends RecyclerView.OnScrollListener {
private static final int HIDE_THRESHOLD = 20;
@rezaiyan
rezaiyan / CustomTabLayoutAnim
Last active September 19, 2017 03:42
Animate tabs of Tablayout with add or removing tabs programmatically
private void addTab(TextView tv) {
View v = tab.getCustomView();
if (v instanceof TextView) {
tv.setScaleX(0f);
tv.setScaleY(0f);
tv.animate()
.scaleX(1f)
.scaleY(1f)
.setInterpolator(new FastOutSlowInInterpolator())
.setDuration(450)