Search in sources :

Example 1 with Recolor

use of com.transitionseverywhere.Recolor in project Transitions-Everywhere by andkulikov.

the class RecolorSample method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_recolor, container, false);
    final ViewGroup transitionsContainer = (ViewGroup) view.findViewById(R.id.transitions_container);
    final Button button = (Button) transitionsContainer.findViewById(R.id.button1);
    button.setOnClickListener(new View.OnClickListener() {

        boolean mColorsInverted;

        @Override
        public void onClick(View v) {
            TransitionManager.beginDelayedTransition(transitionsContainer, new Recolor());
            mColorsInverted = !mColorsInverted;
            button.setTextColor(getResources().getColor(!mColorsInverted ? R.color.second_accent : R.color.accent));
            button.setBackgroundDrawable(new ColorDrawable(getResources().getColor(!mColorsInverted ? R.color.accent : R.color.second_accent)));
        }
    });
    return view;
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) Button(android.widget.Button) ViewGroup(android.view.ViewGroup) View(android.view.View) Recolor(com.transitionseverywhere.Recolor) Nullable(android.support.annotation.Nullable)

Aggregations

ColorDrawable (android.graphics.drawable.ColorDrawable)1 Nullable (android.support.annotation.Nullable)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 Button (android.widget.Button)1 Recolor (com.transitionseverywhere.Recolor)1