To make the icon that you tap on Android appear larger in front of you

Asked 2 years ago, Updated 2 years ago, 40 views

On Android TV, the icon you are selecting is bigger and it is on the front.

I would like to show the same effect on Android apps on my smartphone.
·Tap to display the icon in front of you and increase it.
·Other icons have the same size

If you line up icons in LinearLayout, the icon you tap will be larger, but the other icons will be out of alignment.
How can I program this effect easily?

android

2022-09-30 18:06

1 Answers

In such cases, ScaleAnimation can control the size without affecting the layout.
For example, if you want to change the size when tapping, you can code it as follows (for your information only).

public void onClickImage(View v){
    // treatment at the time of depression
    final ImageView image=(ImageView)v;
    image.setScaleX (1.0f);
    image.setScaleY (1.0f);
    ScaleAnimation animation = new ScaleAnimation (1.0f, 2.5f, 1.0f, 2.5f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    animation.setDuration(300);
    animation.setFillAfter(true);
    image.startAnimation(animation);
}


2022-09-30 18:06

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.