Example usage for android.view.animation Animation RELATIVE_TO_SELF

List of usage examples for android.view.animation Animation RELATIVE_TO_SELF

Introduction

In this page you can find the example usage for android.view.animation Animation RELATIVE_TO_SELF.

Prototype

int RELATIVE_TO_SELF

To view the source code for android.view.animation Animation RELATIVE_TO_SELF.

Click Source Link

Document

The specified dimension holds a float and should be multiplied by the height or width of the object being animated.

Usage

From source file:cn.djangoogle.pull2load.internal.IndicatorLayout.java

public IndicatorLayout(Context context, Pull2LoadBase.Mode mode) {
    super(context);
    mArrowImageView = new ImageView(context);

    Drawable arrowD = ContextCompat.getDrawable(context, R.drawable.indicator_arrow);
    mArrowImageView.setImageDrawable(arrowD);

    final int padding = getResources().getDimensionPixelSize(R.dimen.indicator_internal_padding);
    mArrowImageView.setPadding(padding, padding, padding, padding);
    addView(mArrowImageView);//from   www  .  jav a2 s  . co  m

    int inAnimResId, outAnimResId;
    switch (mode) {
    case PULL_FROM_END:
        inAnimResId = R.anim.slide_in_from_bottom;
        outAnimResId = R.anim.slide_out_to_bottom;
        setBackgroundResource(R.drawable.indicator_bg_bottom);

        // Rotate Arrow so it's pointing the correct way
        mArrowImageView.setScaleType(ScaleType.MATRIX);
        Matrix matrix = new Matrix();
        matrix.setRotate(180f, arrowD.getIntrinsicWidth() / 2f, arrowD.getIntrinsicHeight() / 2f);
        mArrowImageView.setImageMatrix(matrix);
        break;
    default:
    case PULL_FROM_START:
        inAnimResId = R.anim.slide_in_from_top;
        outAnimResId = R.anim.slide_out_to_top;
        setBackgroundResource(R.drawable.indicator_bg_top);
        break;
    }

    mInAnim = AnimationUtils.loadAnimation(context, inAnimResId);
    mInAnim.setAnimationListener(this);

    mOutAnim = AnimationUtils.loadAnimation(context, outAnimResId);
    mOutAnim.setAnimationListener(this);

    final Interpolator interpolator = new LinearInterpolator();
    mRotateAnimation = new RotateAnimation(0, -180, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    mRotateAnimation.setInterpolator(interpolator);
    mRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION);
    mRotateAnimation.setFillAfter(true);

    mResetRotateAnimation = new RotateAnimation(-180, 0, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    mResetRotateAnimation.setInterpolator(interpolator);
    mResetRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION);
    mResetRotateAnimation.setFillAfter(true);

}

From source file:org.videolan.vlc.gui.AboutFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle("VLC " + BuildConfig.VERSION_NAME);
    View v = inflater.inflate(R.layout.about, container, false);

    View aboutMain = v.findViewById(R.id.about_main);
    WebView t = (WebView) v.findViewById(R.id.webview);
    String revision = getString(R.string.build_revision);
    t.loadData(Util.readAsset("licence.htm", "").replace("!COMMITID!", revision), "text/html", "UTF8");

    TextView link = (TextView) v.findViewById(R.id.main_link);
    link.setText(Html.fromHtml(this.getString(R.string.about_link)));

    String builddate = getString(R.string.build_time);
    String builder = getString(R.string.build_host);

    TextView compiled = (TextView) v.findViewById(R.id.main_compiled);
    compiled.setText(builder + " (" + builddate + ")");
    TextView textview_rev = (TextView) v.findViewById(R.id.main_revision);
    textview_rev.setText(getResources().getString(R.string.revision) + " " + revision + " (" + builddate + ")");

    final ImageView logo = (ImageView) v.findViewById(R.id.logo);
    logo.setOnClickListener(new OnClickListener() {
        @Override//from  www  .  ja va2 s  .c o m
        public void onClick(View v) {
            AnimationSet anim = new AnimationSet(true);
            RotateAnimation rotate = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f,
                    Animation.RELATIVE_TO_SELF, 0.5f);
            rotate.setDuration(800);
            rotate.setInterpolator(new DecelerateInterpolator());
            anim.addAnimation(rotate);
            logo.startAnimation(anim);
        }
    });

    List<View> lists = Arrays.asList(aboutMain, t);
    String[] titles = new String[] { getString(R.string.about), getString(R.string.licence) };
    mViewPager = (ViewPager) v.findViewById(R.id.pager);
    mViewPager.setOffscreenPageLimit(MODE_TOTAL - 1);
    mViewPager.setAdapter(new AudioPagerAdapter(lists, titles));

    mTabLayout = (TabLayout) v.findViewById(R.id.sliding_tabs);
    mTabLayout.setupWithViewPager(mViewPager);

    return v;
}

From source file:org.videolan.vlc2.gui.AboutFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ((ActionBarActivity) getActivity()).getSupportActionBar().setTitle("VLC " + getVersion(getActivity()));

    View v = inflater.inflate(R.layout.about, container, false);

    mTabHost = (TabHost) v.findViewById(android.R.id.tabhost);
    mFlingViewGroup = (FlingViewGroup) v.findViewById(R.id.fling_view_group);

    WebView t = (WebView) v.findViewById(R.id.webview);
    String revision = Util.readAsset("revision.txt", "Unknown revision");
    t.loadData(Util.readAsset("licence.htm", "").replace("!COMMITID!", revision), "text/html", "UTF8");

    TextView link = (TextView) v.findViewById(R.id.main_link);
    link.setText(Html.fromHtml(this.getString(R.string.about_link)));

    String builddate = Util.readAsset("builddate.txt", "Unknown");
    String builder = Util.readAsset("builder.txt", "unknown");

    TextView compiled = (TextView) v.findViewById(R.id.main_compiled);
    compiled.setText(builder + " (" + builddate + ")");
    TextView textview_rev = (TextView) v.findViewById(R.id.main_revision);
    textview_rev.setText(getResources().getString(R.string.revision) + " " + revision + " (" + builddate + ")");

    final ImageView logo = (ImageView) v.findViewById(R.id.logo);
    logo.setOnClickListener(new OnClickListener() {
        @Override/*www.j ava2 s.  c  om*/
        public void onClick(View v) {
            AnimationSet anim = new AnimationSet(true);
            RotateAnimation rotate = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f,
                    Animation.RELATIVE_TO_SELF, 0.5f);
            rotate.setDuration(800);
            rotate.setInterpolator(new DecelerateInterpolator());
            anim.addAnimation(rotate);
            logo.startAnimation(anim);
        }
    });

    mTabHost.setup();

    addNewTab(mTabHost, "about", getResources().getString(R.string.about));
    addNewTab(mTabHost, "licence", getResources().getString(R.string.licence));

    mTabHost.setCurrentTab(mCurrentTab);
    mFlingViewGroup.snapToScreen(mCurrentTab);

    mTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
        @Override
        public void onTabChanged(String tabId) {
            mCurrentTab = mTabHost.getCurrentTab();
            mFlingViewGroup.smoothScrollTo(mCurrentTab);
        }
    });

    mFlingViewGroup.setOnViewSwitchedListener(new FlingViewGroup.ViewSwitchListener() {
        @Override
        public void onSwitching(float progress) {
        }

        @Override
        public void onSwitched(int position) {
            mTabHost.setCurrentTab(position);
        }

        @Override
        public void onTouchDown() {
        }

        @Override
        public void onTouchUp() {
        }

        @Override
        public void onTouchClick() {
        }

        @Override
        public void onBackSwitched() {
            MainActivity activity = (MainActivity) getActivity();
            activity.popSecondaryFragment();
        }
    });

    return v;
}

From source file:com.mindorks.framework.mvp.ui.main.MainActivity.java

@Override
public void reloadQuestionnaire(List<Question> questionList) {
    refreshQuestionnaire(questionList);/*from   w  w  w.jav  a  2  s .  com*/
    ScaleAnimation animation = new ScaleAnimation(1.15f, 1, 1.15f, 1, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);

    mCardsContainerView.setAnimation(animation);
    animation.setDuration(100);
    animation.start();
}

From source file:de.fahrgemeinschaft.util.SpinningZebraListFragment.java

@Override
public void onViewCreated(View layout, Bundle state) {
    super.onViewCreated(layout, state);
    layout.setOnClickListener(null);/*  w  w w  .  j a v  a 2s  .  c om*/
    setListAdapter(new CursorAdapter(getActivity(), null, 0) {

        @Override
        public int getCount() {
            if (spinningEnabled)
                return super.getCount() + 1;
            else
                return super.getCount();
        }

        @Override
        public int getViewTypeCount() {
            if (spinningEnabled)
                return 2;
            else
                return 1;
        }

        @Override
        public int getItemViewType(int position) {
            if (!spinningEnabled || position < getCount() - 1)
                return 0;
            else
                return 1;
        }

        @Override
        public View getView(int position, View v, ViewGroup parent) {
            if (!spinningEnabled || position < getCount() - 1)
                v = super.getView(position, v, parent);
            else {
                if (v == null) {
                    v = getLayoutInflater(null).inflate(R.layout.view_spinning_wheel, parent, false);
                }
                ((TextView) v.findViewById(R.id.small)).setText(smallText);
                ((TextView) v.findViewById(R.id.large)).setText(largeText);
                if (spinning && onScreen) {
                    v.findViewById(R.id.progress).startAnimation(rotate);
                } else if (onScreen) {
                    v.findViewById(R.id.progress).clearAnimation();
                }
            }
            if (position % 2 == 0) {
                v.setBackgroundColor(getResources().getColor(R.color.medium_green));
            } else {
                v.setBackgroundColor(getResources().getColor(R.color.almost_medium_green));
            }
            return v;
        }

        @Override
        public View newView(Context ctx, Cursor rides, ViewGroup parent) {
            return getLayoutInflater(null).inflate(R.layout.view_ride_list_entry, parent, false);
        }

        @Override
        public void bindView(View view, Context ctx, Cursor ride) {
            if (ride.getPosition() == ride.getCount())
                return;
            bindListItemView(view, ride);
        }
    });
    registerForContextMenu(getListView());
    rotate = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    rotate.setDuration(600);
    rotate.setRepeatMode(Animation.RESTART);
    rotate.setRepeatCount(Animation.INFINITE);
    stopSpinning(getString(R.string.search_continue));
    if (state != null) {
        code = state.getInt(ID);
        setSpinningEnabled(state.getBoolean(SPIN));
        uri = (Uri) (state.getParcelable(URI));
        getActivity().getSupportLoaderManager().initLoader(code, state, this);
    } else if (uri != null) {
        getActivity().getSupportLoaderManager().restartLoader(code, state, this);
    }
    getListView().requestFocus();
}

From source file:eu.thedarken.rootvalidator.ValidatorFragment.java

private void animateFAB(boolean out) {
    Animation animation;/*w  w w  .  j  ava 2  s  .c  o  m*/
    if (out) {
        animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0,
                Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 1.0f);
        animation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                mFab.setVisibility(View.INVISIBLE);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
    } else {
        animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0,
                Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0);

        animation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
                mFab.setVisibility(View.VISIBLE);
            }

            @Override
            public void onAnimationEnd(Animation animation) {

            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
    }
    animation.setDuration(600);
    animation.setInterpolator(new AnticipateOvershootInterpolator(1.2f));
    mFab.startAnimation(animation);
}

From source file:com.giovanniterlingen.windesheim.view.Adapters.ScheduleAdapter.java

@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
    final TextView lessonName = holder.lessonName;
    final TextView lessonTime = holder.lessonTime;
    final TextView lessonRoom = holder.lessonRoom;
    final TextView lessonComponent = holder.lessonComponent;
    final RelativeLayout menuButton = holder.menuButton;
    final ImageView menuButtonImage = holder.menuButtonImage;
    final View scheduleIdentifier = holder.scheduleIdentifier;

    Lesson lesson = this.lessons[position];
    long databaseDateStart = Long
            .parseLong(lesson.getDate().replaceAll("-", "") + lesson.getStartTime().replaceAll(":", ""));
    long databaseDateEnd = Long
            .parseLong(lesson.getDate().replaceAll("-", "") + lesson.getEndTime().replaceAll(":", ""));

    SimpleDateFormat yearMonthDayDateFormat = CalendarController.getInstance().getYearMonthDayDateTimeFormat();
    long currentDate = Long.parseLong(yearMonthDayDateFormat.format(new Date()));

    lessonName.setText(lesson.getSubject());
    lessonRoom.setText(lesson.getRoom());
    lessonComponent.setText(lesson.getScheduleType() == 2 ? lesson.getClassName() : lesson.getTeacher());
    lessonComponent.setSelected(true);/*from   ww  w .  jav a 2  s  .  com*/

    if (databaseDateStart <= currentDate && databaseDateEnd >= currentDate) {
        lessonTime.setTextColor(ContextCompat.getColor(activity, R.color.colorAccent));
        lessonTime.setText(
                ApplicationLoader.applicationContext.getResources().getString(R.string.lesson_started));
        holder.cardView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Lesson lesson = ScheduleAdapter.this.lessons[holder.getAdapterPosition()];
                if (!lessonTime.getText().toString().equals(ApplicationLoader.applicationContext.getResources()
                        .getString(R.string.lesson_started))) {
                    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
                            Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -1.0f,
                            Animation.RELATIVE_TO_SELF, 0.0f);
                    animation.setDuration(100);
                    lessonTime.setAnimation(animation);
                    lessonTime.setTextColor(ContextCompat.getColor(activity, R.color.colorAccent));
                    lessonTime.setText(ApplicationLoader.applicationContext.getResources()
                            .getString(R.string.lesson_started));
                } else {
                    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
                            Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f,
                            Animation.RELATIVE_TO_SELF, 0.0f);
                    animation.setDuration(100);
                    lessonTime.setAnimation(animation);
                    String lessonTimes = lesson.getStartTime() + " - " + lesson.getEndTime();
                    lessonTime.setTextColor(ContextCompat.getColor(activity, R.color.colorSecondaryText));
                    lessonTime.setText(lessonTimes);
                }
            }
        });
    } else if (databaseDateEnd < currentDate) {
        lessonTime.setTextColor(ContextCompat.getColor(activity, R.color.colorAccent));
        lessonTime.setText(ApplicationLoader.applicationContext.getResources().getString(R.string.finished));
        holder.cardView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Lesson lesson = ScheduleAdapter.this.lessons[holder.getAdapterPosition()];
                if (!lessonTime.getText().toString().equals(
                        ApplicationLoader.applicationContext.getResources().getString(R.string.finished))) {
                    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
                            Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -1.0f,
                            Animation.RELATIVE_TO_SELF, 0.0f);
                    animation.setDuration(100);
                    lessonTime.setAnimation(animation);
                    lessonTime.setTextColor(ContextCompat.getColor(activity, R.color.colorAccent));
                    lessonTime.setText(
                            ApplicationLoader.applicationContext.getResources().getString(R.string.finished));
                } else {
                    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
                            Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f,
                            Animation.RELATIVE_TO_SELF, 0.0f);
                    animation.setDuration(100);
                    lessonTime.setAnimation(animation);
                    String lessonTimes = lesson.getStartTime() + " - " + lesson.getEndTime();
                    lessonTime.setTextColor(ContextCompat.getColor(activity, R.color.colorSecondaryText));
                    lessonTime.setText(lessonTimes);
                }
            }
        });
    } else {
        String lessonTimes = lesson.getStartTime() + " - " + lesson.getEndTime();
        lessonTime.setTextColor(ContextCompat.getColor(activity, R.color.colorSecondaryText));
        lessonTime.setText(lessonTimes);
        holder.cardView.setOnClickListener(null);
    }
    menuButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            menuButtonImage.setImageDrawable(
                    ResourcesCompat.getDrawable(activity.getResources(), R.drawable.overflow_open, null));
            PopupMenu popupMenu = new PopupMenu(activity, menuButton);
            popupMenu.inflate(R.menu.menu_schedule);
            popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                public boolean onMenuItemClick(MenuItem item) {
                    Lesson lesson = ScheduleAdapter.this.lessons[holder.getAdapterPosition()];
                    if (item.getItemId() == R.id.hide_lesson) {
                        showPromptDialog(lesson.getSubject());
                        return true;
                    }
                    if (item.getItemId() == R.id.save_lesson) {
                        showCalendarDialog(lesson.getRowId());
                    }
                    return true;
                }
            });
            popupMenu.setOnDismissListener(new PopupMenu.OnDismissListener() {
                @Override
                public void onDismiss(PopupMenu menu) {
                    menuButtonImage.setImageDrawable(ResourcesCompat.getDrawable(activity.getResources(),
                            R.drawable.overflow_normal, null));
                }
            });
            popupMenu.show();
        }
    });
    scheduleIdentifier.setBackgroundColor(ColorController.getInstance().getColorById(lesson.getScheduleId()));
}

From source file:com.capricorn.ArcMenu.java

private static Animation createItemDisapperAnimation(final long duration, final boolean isClicked) {
    AnimationSet animationSet = new AnimationSet(true);
    animationSet.addAnimation(new ScaleAnimation(1.0f, isClicked ? 2.0f : 0.0f, 1.0f, isClicked ? 2.0f : 0.0f,
            Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f));
    animationSet.addAnimation(new AlphaAnimation(1.0f, 0.0f));

    animationSet.setDuration(duration);//from w w w  . j  a v a 2 s.  c  om
    animationSet.setInterpolator(new DecelerateInterpolator());
    animationSet.setFillAfter(true);

    return animationSet;
}

From source file:com.justwayward.reader.ui.activity.SubjectBookListActivity.java

private void showTagGroup() {
    if (mTagList.isEmpty()) {
        ToastUtils.showToast(getString(R.string.network_error_tips));
        return;/*from ww w  .j a v a 2 s .c  o  m*/
    }
    Animation mShowAction = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
            0.0f, Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
    mShowAction.setDuration(400);
    rsvTags.startAnimation(mShowAction);
    rsvTags.setVisibility(View.VISIBLE);
}

From source file:com.turingtechnologies.materialscrollbar.MaterialScrollBar.java

/**
 * @param context The app's context//from  ww w .  j a v a2 s  .  c om
 * @param recyclerView The recyclerView to which you wish to link the scrollBar
 * @param lightOnTouch Should the handle always be coloured or should it light up on touch and turn grey when released
 */
public MaterialScrollBar(Context context, RecyclerView recyclerView, boolean lightOnTouch) {
    super(context);

    if (!isInEditMode()) {
        a = (Activity) context;
    }

    background = new View(context);
    LayoutParams lp = new RelativeLayout.LayoutParams(Utils.getDP(8, this), LayoutParams.MATCH_PARENT);
    lp.addRule(ALIGN_PARENT_RIGHT);
    background.setLayoutParams(lp);
    background.setBackgroundColor(getResources().getColor(android.R.color.darker_gray));
    ViewHelper.setAlpha(background, 0.4F);

    handle = new View(context);
    lp = new RelativeLayout.LayoutParams(Utils.getDP(8, this), Utils.getDP(48, this));
    lp.addRule(ALIGN_PARENT_RIGHT);
    handle.setLayoutParams(lp);

    this.lightOnTouch = lightOnTouch;
    int colourToSet;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        handleColour = fetchAccentColour(context);
    } else {
        handleColour = Color.parseColor("#9c9c9c");
    }
    if (lightOnTouch) {
        colourToSet = Color.parseColor("#9c9c9c");
    } else {
        colourToSet = handleColour;
    }
    handle.setBackgroundColor(colourToSet);

    addView(background);
    addView(handle);

    setId(R.id.reservedNamedId);
    LayoutParams layoutParams = new LayoutParams(Utils.getDP(20, this), ViewGroup.LayoutParams.MATCH_PARENT);
    layoutParams.addRule(ALIGN_RIGHT, recyclerView.getId());
    layoutParams.addRule(ALIGN_TOP, recyclerView.getId());
    layoutParams.addRule(ALIGN_BOTTOM, recyclerView.getId());
    ((ViewGroup) recyclerView.getParent()).addView(this, layoutParams);
    recyclerView.addOnScrollListener(new ScrollListener(this));
    this.recyclerView = recyclerView;

    setTouchIntercept();

    fade = new BarFade(this);
    fade.start();

    TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT,
            0.0f);
    anim.setFillAfter(true);
    startAnimation(anim);
}