当图像从上到下下降时如何减小图像尺寸?

How can i decrease image size when image is falling from top to bottom?

当图像从上到下下降时如何减小图像尺寸?

我已经通过以下开发了自上而下的流程link

Android Layout Animations from bottom to top and top to bottom on ImageView click

但是我面对一个 problem.How 当图像从上到下下降时我可以减小图像的尺寸吗?

请让我分享您的想法或 link 和代码。

请看下图中我的要求。

您可以对该视图应用比例变换。

Matrix matrix = new Matrix();
matrix.setScale(valueX, valueY);
view.setTransform(matrix); 

对于 imageView

imageView.setImageMatrix(matrix);

解决了我的question.I希望大家喜欢

1.Create anim/zoom_out.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/decelerate_interpolator"
android:fillAfter="true">
<scale
    android:duration="5000"
    android:fromXScale="100%"
    android:fromYScale="100%"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toXScale="50%"
    android:toYScale="50%" />

<translate
    android:duration="5000"
    android:fromYDelta="10%"
    android:toYDelta="50%" />

2.activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<ImageView android:id="@+id/imgvw"
    android:layout_width="wrap_content"
    android:layout_height="250dp"
    android:src="@mipmap/ic_launcher"/>
<Button
    android:id="@+id/btnZoomIn"
    android:layout_below="@+id/imgvw"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Zoom In" android:layout_marginLeft="100dp" />
<Button
    android:id="@+id/btnZoomOut"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/btnZoomIn"
    android:layout_toRightOf="@+id/btnZoomIn"
    android:text="Zoom Out" />
</RelativeLayout>

3.MainActivity.java 文件

public class MainActivity extends AppCompatActivity {
private Button btnzIn;
private Button btnzOut;
private ImageView img;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    btnzIn = (Button)findViewById(R.id.btnZoomIn);
    btnzOut = (Button)findViewById(R.id.btnZoomOut);
    img = (ImageView)findViewById(R.id.imgvw);
  /*  btnzIn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

          //  img.startAnimation(AnimationUtils.loadAnimation(getApplicationContext(),R.anim.zoom_in));
            img.startAnimation(AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_down));
           // img.clearAnimation();
        }
    });*/
    btnzOut.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

        //    img.startAnimation(AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_up));
            img.startAnimation(AnimationUtils.loadAnimation(getApplicationContext(),R.anim.zoom_out));

        }
    });
}