设为首页 加入收藏

TOP

android---动画入门(一)(三)
2019-09-01 23:13:07 】 浏览:52
Tags:android--- 动画 入门
;0" android:fromXDelta="0" android:toYDelta="0" android:toXDelta="50%"/> <rotate android:fromDegrees="0" android:toDegrees="90" /> </set>

  

  • 在布局中放一个TextView
  • <?xml version="1.0" encoding="utf-8"?>
    <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context="com.learning.animationapplication.MainActivity">
    
        <TextView
            android:id="@+id/tv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Hello World!"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            android:background="@android:color/holo_blue_bright"/>
    
    </android.support.constraint.ConstraintLayout>
    

      

  • 在Activity中加载动画
  •     

    package com.learning.animationapplication;
    
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.animation.Animation;
    import android.view.animation.AnimationUtils;
    import android.widget.TextView;
    
    public class MainActivity extends AppCompatActivity {
    
        private TextView tv;
        private Animation animation;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            tv = findViewById(R.id.tv);
            animation = AnimationUtils.loadAnimation(this, R.anim.set);//加载动画
            tv.startAnimation(animation);//启动动画,并且是立即启动
        }
    }
    

      

     

    代码实现,不用xml标签

    举例:

     

     

     

    首页 上一页 1 2 3 下一页 尾页 3/3/3
    】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
    上一篇还在用AIDL吗?试试EasyMessenger.. 下一篇Android开发—— Tablayout的使用

    最新文章

    热门文章

    Hot 文章

    Python

    C 语言

    C++基础

    大数据基础

    linux编程基础

    C/C++面试题目