Java Code Examples for android.view.View.setStateListAnimator()

The following are Jave code examples for showing how to use setStateListAnimator() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: cwac-crossport   File:   Source Code and License Vote up 6 votes
   * Creates and sets a {@link StateListAnimator} with a custom elevation value
static void setDefaultAppBarLayoutStateListAnimator(final View view, final float elevation) {
  final int dur = view.getResources().getInteger(R.integer.app_bar_elevation_anim_duration);

  final StateListAnimator sla = new StateListAnimator();

  // Enabled and collapsible, but not collapsed means not elevated
      sla.addState(new int[]{android.R.attr.enabled, R.attr.state_collapsible,
      ObjectAnimator.ofFloat(view, "elevation", 0f).setDuration(dur));

  // Default enabled state
      sla.addState(new int[]{android.R.attr.enabled},
      ObjectAnimator.ofFloat(view, "elevation", elevation).setDuration(dur));

  // Disabled state
      sla.addState(new int[0],
              ObjectAnimator.ofFloat(view, "elevation", 0).setDuration(0));

Example 2
Project: cwac-crossport   File:   Source Code and License Vote up 5 votes
static void setStateListAnimatorFromAttrs(View view, AttributeSet attrs,
         int defStyleAttr,  int defStyleRes) {
  final Context context = view.getContext();
      final TypedArray a = context.obtainStyledAttributes(attrs, STATE_LIST_ANIM_ATTRS,
              defStyleAttr, defStyleRes);
  try {
    if (a.hasValue(0)) {
              StateListAnimator sla = AnimatorInflater.loadStateListAnimator(context,
                      a.getResourceId(0, 0));
  } finally {