Java Code Examples for android.widget.ImageView#setScaleX()

The following examples show how to use android.widget.ImageView#setScaleX() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CellularTile.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreateTileView(View tileView) throws Throwable {
    super.onCreateTileView(tileView);

    if (isPrimary() && hasField(tileView, "mIconFrame") && !Utils.isOxygenOs35Rom()) {
        mDataOffView = new ImageView(mContext);
        mDataOffView.setImageDrawable(mGbContext.getDrawable(R.drawable.ic_mobile_data_off));
        mDataOffView.setVisibility(View.GONE);
        FrameLayout iconFrame = (FrameLayout) XposedHelpers.getObjectField(tileView, "mIconFrame");
        iconFrame.addView(mDataOffView, FrameLayout.LayoutParams.WRAP_CONTENT,
                FrameLayout.LayoutParams.WRAP_CONTENT);
        if (mScalingFactor != 1f) {
            mDataOffView.setScaleX(mScalingFactor);
            mDataOffView.setScaleY(mScalingFactor);
        }
        if (PhoneWrapper.hasMsimSupport()) {
            FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mDataOffView.getLayoutParams();
            int marginPx = Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, -4,
                    mContext.getResources().getDisplayMetrics()));
            lp.leftMargin = marginPx;
            lp.topMargin = Math.round(marginPx/2f);
            mDataOffView.setLayoutParams(lp);
        }
    }
}
 
Example 2
Source File: CustomTransformer.java    From SwipeSectorLayout with MIT License 6 votes vote down vote up
@Override
public void transformPage(View view, float position) {

    int pageWidth = view.getWidth();
    ImageView imgView = (ImageView)view.findViewById(R.id.img);
    if (position < -1) { // [-Infinity,-1)
        // This page is way off-screen to the left.
    } else if (position <= 0) { // [-1,0]

        view.setAlpha((1 - MIN_ALPHA) * (1 - Math.abs(position)) + MIN_ALPHA);
        float transX = pageWidth * -position;
        view.setTranslationX(transX);
        float scale = (DEFAULT_SCALE - 1.0f) * (1 - Math.abs(position)) + 1;
        imgView.setScaleX(scale);
        imgView.setScaleY(scale);

    } else if (position <= 1) { // (0,1]
        imgView.setAlpha(1.0f);
        imgView.setScaleX(DEFAULT_SCALE);
        imgView.setScaleY(DEFAULT_SCALE);

    } else { // (1,+Infinity]
        // This page is way off-screen to the right.
    }
}
 
Example 3
Source File: DetailActivity.java    From EasyTransition with Apache License 2.0 6 votes vote down vote up
private void initOtherViews() {
    layoutAbout = (LinearLayout) findViewById(R.id.layout_about);
    layoutAbout.setVisibility(View.VISIBLE);
    layoutAbout.setAlpha(0);
    layoutAbout.setTranslationY(-30);
    layoutAbout.animate()
            .setDuration(300)
            .alpha(1)
            .translationY(0);

    ivAdd = (ImageView) findViewById(R.id.iv_add);
    ivAdd.setVisibility(View.VISIBLE);
    ivAdd.setScaleX(0);
    ivAdd.setScaleY(0);
    ivAdd.animate()
            .setDuration(200)
            .scaleX(1)
            .scaleY(1);
}
 
Example 4
Source File: ScreenshotFragment.java    From DGameDetail with Apache License 2.0 6 votes vote down vote up
/**
 * 恢复
 *
 * @param img
 */
private void resumeRotation(ImageView img, boolean useAnim) {
    int w = AndroidUtils.getWindowWidth(getActivity()), h = AndroidUtils.getWindowHeight(getActivity());
    int iw = img.getMeasuredWidth(), ih = img.getMeasuredHeight();
    if (useAnim) {
        ObjectAnimator move = ObjectAnimator.ofFloat(img, "translationY", (h - ih) / 2f, 0);
        move.setDuration(400);
        ObjectAnimator scaleX = ObjectAnimator.ofFloat(img, "scaleX", (float) h / iw, 1.0f);
        ObjectAnimator scaleY = ObjectAnimator.ofFloat(img, "scaleY", (float) w / ih, 1.0f);
        ObjectAnimator rotation = ObjectAnimator.ofFloat(img, "rotation", 90f, 0f);
        AnimatorSet set = new AnimatorSet();
        set.play(scaleX).with(scaleY).with(rotation).with(move);
        set.setDuration(600);
        set.start();
    } else {
        img.setTranslationY(0f);
        img.setScaleX(1.0f);
        img.setScaleY(1.0f);
        img.setRotation(0f);
    }
}
 
Example 5
Source File: MoveAnimMode.java    From ECardFlow with MIT License 5 votes vote down vote up
@Override
public void transformPage(ImageView ivBg, float position, int direction) {
    ivBg.setScaleX(mScale);
    ivBg.setScaleY(mScale);
    float totalMoveWidth = ivBg.getWidth() * ((mScale - 1) / 2);
    int lastPosition = Math.round(position);
    float mFraction;
    if (lastPosition % 2 == 0) {
        mFraction = -1 * (float) Math.sin(Math.PI * position);
    } else {
        mFraction = (float) Math.sin(Math.PI * position);
    }
    ivBg.setTranslationX(totalMoveWidth * mFraction);
}
 
Example 6
Source File: CrossMoveAnimMode.java    From ECardFlow with MIT License 5 votes vote down vote up
@Override
public void transformPage(ImageView ivBg, float position, int direction) {
    ivBg.setScaleX(mScale);
    ivBg.setScaleY(mScale);
    float totalMoveWidth = ivBg.getWidth() * ((mScale - 1) / 2);
    int lastPosition = Math.round(position);
    float mFraction;
    if (lastPosition % 2 == 0) {
        mFraction = -1 * (float) Math.sin(Math.PI * position);
    } else {
        mFraction = (float) Math.sin(Math.PI * position);
    }
    ivBg.setTranslationY(totalMoveWidth * mFraction);
}
 
Example 7
Source File: FolderAdapter.java    From Rey-MusicPlayer with Apache License 2.0 5 votes vote down vote up
public ItemHolder(View itemView) {
    super(itemView);

    mIconImage = (ImageView) itemView.findViewById(R.id.listViewLeftIcon);

    mTitle = (TextView) itemView.findViewById(R.id.listViewTitleText);
    mSubTitle = (TextView) itemView.findViewById(R.id.listViewSubText);
    duration = (TextView) itemView.findViewById(R.id.listViewRightSubText);
    duration.setVisibility(View.INVISIBLE);

    mTitle.setTypeface(TypefaceHelper.getTypeface(itemView.getContext().getApplicationContext(), TypefaceHelper.FUTURA_BOOK));
    mSubTitle.setTypeface(TypefaceHelper.getTypeface(itemView.getContext().getApplicationContext(), TypefaceHelper.FUTURA_BOOK));

    mOverFlow = (ImageView) itemView.findViewById(R.id.listViewOverflow);

    mOverFlow.setOnClickListener(this);
    mOverFlow.setVisibility(View.VISIBLE);
    mOverFlow.setOnClickListener(this);
    itemView.setOnClickListener(this);

    RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) itemView.getLayoutParams();
    params.height = (int) mApp.convertDpToPixels(72.0f, mContext);
    itemView.setLayoutParams(params);

    mIconImage.setScaleX(0.55f);
    mIconImage.setScaleY(0.55f);

}
 
Example 8
Source File: LessonB.java    From SchoolQuest with GNU General Public License v3.0 5 votes vote down vote up
public void resetBars() {
    skill = 0;
    tempSkill = 0;
    attn = 0;
    time = 0;
    ImageView attnBar = GameActivity.getInstance().findViewById(R.id.lesson_b_attn_bar_fill);
    ViewGroup.LayoutParams attnParams = attnBar.getLayoutParams();
    attnParams.width = 1;
    attnBar.setLayoutParams(attnParams);

    ImageView skillBar = GameActivity.getInstance().findViewById(R.id.lesson_b_skill_bar_fill);
    ViewGroup.LayoutParams skillParams = skillBar.getLayoutParams();
    skillParams.width = 1;
    skillBar.setLayoutParams(skillParams);

    ImageView tempSkillBar =
            GameActivity.getInstance().findViewById(R.id.lesson_b_skill_temp_bar_fill);
    ViewGroup.LayoutParams tempSkillParams = tempSkillBar.getLayoutParams();
    tempSkillParams.width = 1;
    tempSkillBar.setLayoutParams(tempSkillParams);

    ImageView timeBar = GameActivity.getInstance().findViewById(R.id.lesson_b_time_bar_fill);
    ViewGroup.LayoutParams timeParams = timeBar.getLayoutParams();
    timeParams.width = 1;
    timeBar.setLayoutParams(timeParams);

    ImageView craftBar1 = GameActivity.getInstance().findViewById(R.id.lesson_b_craft_bar_1point);
    craftBar1.setScaleX(0);

    ImageView craftBar2 = GameActivity.getInstance().findViewById(R.id.lesson_b_craft_bar_2point);
    craftBar2.setScaleX(0);
}
 
Example 9
Source File: BubbleView.java    From BubbleActions with Apache License 2.0 5 votes vote down vote up
public BubbleView(Context context) {
    super(context);

    setOrientation(VERTICAL);
    LayoutInflater.from(context).inflate(R.layout.bubble_actions_bubble_item, this, true);
    textView = (TextView) getChildAt(0);
    imageView = (ImageView) getChildAt(1);
    imageView.setOnDragListener(dragListener);
    imageView.setScaleX(DESELECTED_SCALE);
    imageView.setScaleY(DESELECTED_SCALE);
}
 
Example 10
Source File: IntroPageTransformer.java    From Saude-no-Mapa with MIT License 5 votes vote down vote up
private void transformOne(View page, float position) {
    int pageWidth = page.getWidth();
    float pageWidthTimesPosition = pageWidth * position;
    float absPosition = Math.abs(position);
    ImageView backgroundImage = (ImageView) page.findViewById(R.id.image_view);
    TextView titleView = (TextView) page.findViewById(R.id.title_text);
    TextView descriptionView = (TextView) page.findViewById(R.id.description);
    View indicatorView1 = page.findViewById(R.id.indicator_view_1);
    View indicatorView2 = page.findViewById(R.id.indicator_view_2);
    View indicatorView3 = page.findViewById(R.id.indicator_view_3);

    if (position <= -1.0f || position >= 1.0f) {
    } else if (position == 0.0f) {
    } else {
        if (pageWidthTimesPosition > 1) {
            backgroundImage.setScaleY(1 + (pageWidthTimesPosition * SCALE_Y_FACTOR));
            backgroundImage.setScaleX(1 + (pageWidthTimesPosition * SCALE_Y_FACTOR));
        } else if (pageWidthTimesPosition < 1) {
            backgroundImage.setScaleY(1 - (pageWidthTimesPosition * SCALE_Y_FACTOR));
            backgroundImage.setScaleX(1 - (pageWidthTimesPosition * SCALE_Y_FACTOR));
        }

        titleView.setTranslationX(pageWidthTimesPosition * X_MIN_VEL);
        descriptionView.setTranslationX(pageWidthTimesPosition * X_MAX_VEL);

        indicatorView1.setTranslationX(-pageWidthTimesPosition * 1f);
        indicatorView2.setAlpha(1.0f - (5 * absPosition));
        indicatorView3.setAlpha(1.0f - (5 * absPosition));
    }
}
 
Example 11
Source File: IntroPageTransformer.java    From Saude-no-Mapa with MIT License 5 votes vote down vote up
private void transformTwo(View page, float position) {
    int pageWidth = page.getWidth();
    float pageWidthTimesPosition = pageWidth * position;
    float absPosition = Math.abs(position);
    ImageView backgroundImage = (ImageView) page.findViewById(R.id.image_view);
    TextView titleView = (TextView) page.findViewById(R.id.title_text);
    TextView descriptionView = (TextView) page.findViewById(R.id.description);
    View indicatorView1 = page.findViewById(R.id.indicator_view_1);
    View indicatorView2 = page.findViewById(R.id.indicator_view_2);
    View indicatorView3 = page.findViewById(R.id.indicator_view_3);

    if (position <= -1.0f || position >= 1.0f) {
    } else if (position == 0.0f) {
    } else {
        if (pageWidthTimesPosition > 1) {
            backgroundImage.setScaleY(1 + (pageWidthTimesPosition * SCALE_Y_FACTOR));
            backgroundImage.setScaleX(1 + (pageWidthTimesPosition * SCALE_Y_FACTOR));
        } else if (pageWidthTimesPosition < 1) {
            backgroundImage.setScaleY(1 - (pageWidthTimesPosition * SCALE_Y_FACTOR));
            backgroundImage.setScaleX(1 - (pageWidthTimesPosition * SCALE_Y_FACTOR));
        }

        titleView.setTranslationX(pageWidthTimesPosition * X_MIN_VEL);
        descriptionView.setTranslationX(pageWidthTimesPosition * X_MAX_VEL);

        indicatorView2.setTranslationX(-pageWidthTimesPosition * 1f);
        indicatorView1.setAlpha(1.0f - (5 * absPosition));
        indicatorView3.setAlpha(1.0f - (5 * absPosition));
    }
}
 
Example 12
Source File: IntroPageTransformer.java    From Saude-no-Mapa with MIT License 5 votes vote down vote up
private void transformThree(View page, float position) {
    int pageWidth = page.getWidth();
    float pageWidthTimesPosition = pageWidth * position;
    float absPosition = Math.abs(position);
    ImageView backgroundImage = (ImageView) page.findViewById(R.id.image_view);
    TextView titleView = (TextView) page.findViewById(R.id.title_text);
    TextView descriptionView = (TextView) page.findViewById(R.id.description);
    View indicatorView1 = page.findViewById(R.id.indicator_view_1);
    View indicatorView2 = page.findViewById(R.id.indicator_view_2);
    View indicatorView3 = page.findViewById(R.id.indicator_view_3);

    if (position <= -1.0f || position >= 1.0f) {
    } else if (position == 0.0f) {
    } else {
        if (pageWidthTimesPosition > 1) {
            backgroundImage.setScaleY(1 + (pageWidthTimesPosition * SCALE_Y_FACTOR));
            backgroundImage.setScaleX(1 + (pageWidthTimesPosition * SCALE_Y_FACTOR));
        } else if (pageWidthTimesPosition < 1) {
            backgroundImage.setScaleY(1 - (pageWidthTimesPosition * SCALE_Y_FACTOR));
            backgroundImage.setScaleX(1 - (pageWidthTimesPosition * SCALE_Y_FACTOR));
        }

        titleView.setTranslationX(pageWidthTimesPosition * X_MIN_VEL);
        descriptionView.setTranslationX(pageWidthTimesPosition * X_MAX_VEL);

        indicatorView3.setTranslationX(-pageWidthTimesPosition * 1f);
        indicatorView1.setAlpha(1f - (5 * absPosition));
        indicatorView2.setAlpha(1f - (5 * absPosition));
    }
}
 
Example 13
Source File: JamTrendArrowImpl.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean update(final Double mgdl) {
    final ImageView myArrow = getMyArrow();
    if (mgdl != null) {

        final float newRotation = calculateRotation(mgdl);

        // not initialized
        if (lastRotation == -1000) {
            lastRotation = newRotation;
        }

        final RotateAnimation rotateAnimation = new RotateAnimation(
                lastRotation,
                newRotation,
                Animation.RELATIVE_TO_SELF,
                0.5f,
                Animation.RELATIVE_TO_SELF,
                0.5f);
        rotateAnimation.setDuration(1000);
        rotateAnimation.setInterpolator(new DecelerateInterpolator(1.5f));
        rotateAnimation.setFillAfter(true);

        lastRotation = newRotation;

        myArrow.startAnimation(rotateAnimation);
        final float newScale = calculateScale(mgdl);
        myArrow.setScaleX(newScale * getSourceScaleAdjust());
        myArrow.setScaleY(newScale * getSourceScaleAdjust());
        myArrow.setVisibility(View.VISIBLE);

        myArrow.setColorFilter(colorfilter);

        return false;
    } else {
        myArrow.setVisibility(View.GONE);
        myArrow.setScaleX(0.0001f);
        myArrow.setScaleY(0.0001f);
    }
    return true;
}
 
Example 14
Source File: AnimationDetailFragment.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.easy_animation_fragment_animation_detail,
            container, false);

    mPlayView = rootView.findViewById(R.id.imgPlay);
    card = (ImageView) rootView.findViewById(R.id.imgTarget);
    mPlayView.setOnClickListener(this);
    card2 = (ImageView) rootView.findViewById(R.id.imgBehind);
    target = rootView.findViewById(R.id.textView1);
    card2.setVisibility(View.INVISIBLE);
    tvCode = (TextView) rootView.findViewById(R.id.tv_code);

    if (mItem.code != null && mItem.code.length() > 0) {
        tvCode.setVisibility(View.VISIBLE);
        tvCode.setText(mItem.code);
    } else {
        tvCode.setVisibility(View.INVISIBLE);
    }

    // Differentiates the images for all animations
    if (mItem.id <= 5) {
        card.setImageResource(R.drawable.test);
    } else if (mItem.id > 5 && mItem.id <= 10) {
        card.setImageResource(R.drawable.test_back);
    } else if (mItem.id > 10 && mItem.id <= 20) {
        card.setImageResource(R.drawable.test_back1);
    } else {
        card.setImageResource(R.drawable.test_back2);
    }

    mPlayView.setLayoutParams(card.getLayoutParams());

    // Scales the image smaller for PathAnimation

    if (mItem.id == 14) {
        card.setImageResource(R.drawable.test);
        card.setScaleX(0.5f);
        card.setScaleY(0.5f);
    }

    // Sets view to <code>View.INVISIBLE</code> for entrance animations
    if (mItem.id == 5 || mItem.id == 11 || mItem.id == 15 || mItem.id == 18
            || mItem.id == 21 || mItem.id == 22 || mItem.id == 26) {
        card.setVisibility(View.INVISIBLE);

    }

    // Sets destination view to <code>View.VISIBLE</code> only for
    // TransferAnimation

    if (mItem.id != 25) {
        target.setVisibility(View.INVISIBLE);

    }

    return rootView;
}
 
Example 15
Source File: AnimationDetailFragment.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.easy_animation_fragment_animation_detail,
            container, false);

    mPlayView = rootView.findViewById(R.id.imgPlay);
    card = (ImageView) rootView.findViewById(R.id.imgTarget);
    mPlayView.setOnClickListener(this);
    card2 = (ImageView) rootView.findViewById(R.id.imgBehind);
    target = rootView.findViewById(R.id.textView1);
    card2.setVisibility(View.INVISIBLE);
    tvCode = (TextView) rootView.findViewById(R.id.tv_code);

    if (mItem.code != null && mItem.code.length() > 0) {
        tvCode.setVisibility(View.VISIBLE);
        tvCode.setText(mItem.code);
    } else {
        tvCode.setVisibility(View.INVISIBLE);
    }

    // Differentiates the images for all animations
    if (mItem.id <= 5) {
        card.setImageResource(R.drawable.test);
    } else if (mItem.id > 5 && mItem.id <= 10) {
        card.setImageResource(R.drawable.test_back);
    } else if (mItem.id > 10 && mItem.id <= 20) {
        card.setImageResource(R.drawable.test_back1);
    } else {
        card.setImageResource(R.drawable.test_back2);
    }

    mPlayView.setLayoutParams(card.getLayoutParams());

    // Scales the image smaller for PathAnimation

    if (mItem.id == 14) {
        card.setImageResource(R.drawable.test);
        card.setScaleX(0.5f);
        card.setScaleY(0.5f);
    }

    // Sets view to <code>View.INVISIBLE</code> for entrance animations
    if (mItem.id == 5 || mItem.id == 11 || mItem.id == 15 || mItem.id == 18
            || mItem.id == 21 || mItem.id == 22 || mItem.id == 26) {
        card.setVisibility(View.INVISIBLE);

    }

    // Sets destination view to <code>View.VISIBLE</code> only for
    // TransferAnimation

    if (mItem.id != 25) {
        target.setVisibility(View.INVISIBLE);

    }

    return rootView;
}
 
Example 16
Source File: SparkleDemoActivity.java    From SparkleMotion with MIT License 4 votes vote down vote up
/**
 * Build the third page Decors: a {@link PaperPlaneView } that draws a path within the page, and
 * two clouds the slide down as the page scrolls.
 */
private void buildDecorForPage2(SparkleViewPagerLayout parent, SparkleMotion sparkleMotion) {

    // Setup PaperPlaneView.
    final PaperPlaneView view = (PaperPlaneView) LayoutInflater.from(parent.getContext())
            .inflate(R.layout.sparkle_page_2_plane, parent, false);

    Decor decor = new Decor.Builder(view)
            .setPage(Page.singlePage(1))
            .behindViewPage()
            .slideOut()
            .build();

    sparkleMotion.animate(new Animation(Page.singlePage(1)) {
        @Override
        public void onAnimate(View v, float offset, float offsetInPixel) {
            offset = Math.abs(offset);
            view.animate(offset);
        }
    }).on(decor);

    final int cloudMargin = getResources().getDimensionPixelOffset(R.dimen.icon_cloud_margin);
    final Drawable cloud = ContextCompat.getDrawable(this, R.drawable.cloud);

    // Setup small cloud.
    FrameLayout.LayoutParams lpSmallCloud =
            new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lpSmallCloud.leftMargin = cloudMargin;
    lpSmallCloud.topMargin = cloudMargin;

    ImageView smallCloud = new ImageView(parent.getContext());
    smallCloud.setLayoutParams(lpSmallCloud);
    smallCloud.setTranslationY(-cloud.getIntrinsicHeight() - lpSmallCloud.topMargin);
    smallCloud.setImageDrawable(cloud);

    // Setup large cloud.
    FrameLayout.LayoutParams lpBigCloud =
            new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lpBigCloud.gravity = Gravity.RIGHT;
    lpBigCloud.topMargin = (int) (cloud.getIntrinsicHeight() * 1.6f);

    ImageView bigCloud = new ImageView(parent.getContext());
    bigCloud.setLayoutParams(lpBigCloud);
    bigCloud.setTranslationY(-cloud.getIntrinsicHeight() * 1.6f - lpBigCloud.topMargin);
    bigCloud.setScaleX(1.6f);
    bigCloud.setScaleY(1.6f);
    bigCloud.setImageDrawable(cloud);

    Page page = Page.singlePage(1);
    Decor cloudDecor1 =
            new Decor.Builder(smallCloud).setPage(page).slideOut().withLayer().build();
    Decor cloudDecor2 =
            new Decor.Builder(bigCloud).setPage(page).slideOut().withLayer().build();

    TranslationAnimation translationAnimation1 =
            new TranslationAnimation(page, 0, smallCloud.getTranslationY(), 0, 0, true);
    TranslationAnimation translationAnimation2 =
            new TranslationAnimation(page, 0, bigCloud.getTranslationY(), 0, 0, true);

    sparkleMotion.animate(translationAnimation1).on(cloudDecor1);
    sparkleMotion.animate(translationAnimation2).on(cloudDecor2);
}
 
Example 17
Source File: JamTrendArrowImpl.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean update(final Double mgdl) {
    final ImageView myArrow = getMyArrow();
    if (mgdl != null) {

        final float newRotation = calculateRotation(mgdl);

        // not initialized
        if (lastRotation == -1000) {
            lastRotation = newRotation;
        }

        final RotateAnimation rotateAnimation = new RotateAnimation(
                lastRotation,
                newRotation,
                Animation.RELATIVE_TO_SELF,
                0.5f,
                Animation.RELATIVE_TO_SELF,
                0.5f);
        rotateAnimation.setDuration(1000);
        rotateAnimation.setInterpolator(new DecelerateInterpolator(1.5f));
        rotateAnimation.setFillAfter(true);

        lastRotation = newRotation;

        myArrow.startAnimation(rotateAnimation);
        final float newScale = calculateScale(mgdl);
        myArrow.setScaleX(newScale * getSourceScaleAdjust());
        myArrow.setScaleY(newScale * getSourceScaleAdjust());
        myArrow.setVisibility(View.VISIBLE);

        myArrow.setColorFilter(colorfilter);

        return false;
    } else {
        myArrow.setVisibility(View.GONE);
        myArrow.setScaleX(0.0001f);
        myArrow.setScaleY(0.0001f);
    }
    return true;
}
 
Example 18
Source File: UIHelper.java    From Android-Application-ZJB with Apache License 2.0 4 votes vote down vote up
/**
 * 照片双击点赞动画
 */
public static void animatePhotoLike(final ImageView likeBg, final ImageView likeIcon) {
    likeBg.setVisibility(View.VISIBLE);
    likeIcon.setVisibility(View.VISIBLE);

    likeBg.setScaleY(0.1f);
    likeBg.setScaleX(0.1f);
    likeBg.setAlpha(1f);
    likeIcon.setScaleY(0.1f);
    likeIcon.setScaleX(0.1f);

    AnimatorSet animatorSet = new AnimatorSet();

    ObjectAnimator bgScaleYAnim = ObjectAnimator.ofFloat(likeBg, "scaleY", 0.1f, 1f);
    bgScaleYAnim.setDuration(200);
    bgScaleYAnim.setInterpolator(DECCELERATE_INTERPOLATOR);
    ObjectAnimator bgScaleXAnim = ObjectAnimator.ofFloat(likeBg, "scaleX", 0.1f, 1f);
    bgScaleXAnim.setDuration(200);
    bgScaleXAnim.setInterpolator(DECCELERATE_INTERPOLATOR);
    ObjectAnimator bgAlphaAnim = ObjectAnimator.ofFloat(likeBg, "alpha", 1f, 0f);
    bgAlphaAnim.setDuration(200);
    bgAlphaAnim.setStartDelay(150);
    bgAlphaAnim.setInterpolator(DECCELERATE_INTERPOLATOR);

    ObjectAnimator imgScaleUpYAnim = ObjectAnimator.ofFloat(likeIcon, "scaleY", 0.1f, 1f);
    imgScaleUpYAnim.setDuration(300);
    imgScaleUpYAnim.setInterpolator(DECCELERATE_INTERPOLATOR);
    ObjectAnimator imgScaleUpXAnim = ObjectAnimator.ofFloat(likeIcon, "scaleX", 0.1f, 1f);
    imgScaleUpXAnim.setDuration(300);
    imgScaleUpXAnim.setInterpolator(DECCELERATE_INTERPOLATOR);

    ObjectAnimator imgScaleDownYAnim = ObjectAnimator.ofFloat(likeIcon, "scaleY", 1f, 0f);
    imgScaleDownYAnim.setDuration(300);
    imgScaleDownYAnim.setInterpolator(ACCELERATE_INTERPOLATOR);
    ObjectAnimator imgScaleDownXAnim = ObjectAnimator.ofFloat(likeIcon, "scaleX", 1f, 0f);
    imgScaleDownXAnim.setDuration(300);
    imgScaleDownXAnim.setInterpolator(ACCELERATE_INTERPOLATOR);

    animatorSet.playTogether(bgScaleYAnim, bgScaleXAnim, bgAlphaAnim, imgScaleUpYAnim, imgScaleUpXAnim);
    animatorSet.play(imgScaleDownYAnim).with(imgScaleDownXAnim).after(imgScaleUpYAnim);

    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            resetLikeAnimationState(likeBg, likeIcon);
        }
    });
    animatorSet.start();
}
 
Example 19
Source File: ScaleAnimMode.java    From ECardFlow with MIT License 4 votes vote down vote up
@Override
public void transformPage(ImageView ivBg, float position, int direction) {
    float mFraction = mScaleRate * (float) Math.abs(Math.sin(Math.PI * position));
    ivBg.setScaleX(1 + mFraction);
    ivBg.setScaleY(1 + mFraction);
}
 
Example 20
Source File: SearchBookActivity.java    From MyBookshelf with GNU General Public License v3.0 4 votes vote down vote up
private void initSearchView() {
    mSearchAutoComplete = searchView.findViewById(R.id.search_src_text);
    searchView.setQueryHint(getString(R.string.search_book_key));
    //获取到TextView的控件
    mSearchAutoComplete.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
    mSearchAutoComplete.setPadding(15, 0, 0, 0);
    searchView.onActionViewExpanded();
    LinearLayout editFrame = searchView.findViewById(androidx.appcompat.R.id.search_edit_frame);
    ImageView closeButton = searchView.findViewById(androidx.appcompat.R.id.search_close_btn);
    ImageView goButton = searchView.findViewById(androidx.appcompat.R.id.search_go_btn);
    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) editFrame.getLayoutParams();
    params.setMargins(20, 0, 10, 0);
    editFrame.setLayoutParams(params);
    closeButton.setScaleX(0.9f);
    closeButton.setScaleY(0.9f);
    closeButton.setPadding(0, 0, 0, 0);
    goButton.setPadding(0, 0, 0, 0);
    searchView.setSubmitButtonEnabled(true);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            if (TextUtils.isEmpty(query))
                return false;
            searchKey = query.trim();
            if (!searchKey.toLowerCase().startsWith("set:")) {
                toSearch();
                searchView.clearFocus();
                return false;
            } else {
                parseSecretCode(searchKey);
                finish();
                return false;
            }
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            if (newText != null) {
                List<BookInfoBean> beans = BookshelfHelp.searchBookInfo(newText);
                searchBookshelfAdapter.setItems(beans);
                if (beans.size() > 0) {
                    tvBookshelf.setVisibility(View.VISIBLE);
                    rvBookshelf.setVisibility(View.VISIBLE);
                } else {
                    tvBookshelf.setVisibility(View.GONE);
                    rvBookshelf.setVisibility(View.GONE);
                }
            } else {
                tvBookshelf.setVisibility(View.GONE);
                rvBookshelf.setVisibility(View.GONE);
            }
            if (!newText.toLowerCase().startsWith("set")) {
                mPresenter.querySearchHistory(newText);
            } else {
                showHideSetting();
            }
            return false;
        }
    });
    searchView.setOnQueryTextFocusChangeListener((view, b) -> {
        showHistory = b;
        if (!b && searchView.getQuery().toString().trim().equals("")) {
            finish();
        }
        if (showHistory) {
            fabSearchStop.hide();
            mPresenter.stopSearch();
        }
        openOrCloseHistory(showHistory);
    });
}