艺术探索(传统动画位移)

1.res下创建anim文件夹

2.在anim文件夹下创建anim_viewla.xml

3.内容

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android ="http://schemas.android.com/apk/res/android"
android:fillAfter ="true"
android:zAdjustment = "normal"
>
<translate
android:duration = "100"
android:fromXDelta ="0"
android:fromYDelta ="0"
android:interpolator="@android:anim/linear_interpolator"
android:toXDelta ="100"        //移动后
android:toYDelta ="100"        //移动后
/>

</set>

4.layout下xml文件(myviewa.xml)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:id="@+id/acg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="安超广"
android:textSize="30sp"
android:layout_gravity="center_horizontal"
/>
</LinearLayout>

5.activity(MyView)
package comt.example.dell_pc.arttest;


import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;


public class MyView extends AppCompatActivity {
private Context mContext;
private Button acg;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.myviewa);
Animation animation = AnimationUtils.loadAnimation(this, R.anim.anim_viewla);
acg = findViewById(R.id.acg);
acg.startAnimation(animation);
}
}



posted @ 2019-05-30 16:43  小#安  阅读(162)  评论(0编辑  收藏  举报