zoukankan      html  css  js  c++  java
  • AndroidUI 布局动画-为布局添加动画

    除了可以为视图添加动画以外,还可以为视图的布局添加动画;

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context=".MainActivity" >
    
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:orientation="vertical" 
            android:id="@+id/linerLayout1">
    
            <Button
                android:id="@+id/button1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Button" />
    
            <Button
                android:id="@+id/button1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Button" />
            <Button
                android:id="@+id/button1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Button" />
            <Button
                android:id="@+id/button1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Button" />
            <Button
                android:id="@+id/button1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Button" />
        </LinearLayout>
    
    </RelativeLayout>

    代码:

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            LinearLayout layout= (LinearLayout)findViewById(R.id.linerLayout1);
            
            //设置缩放动画
            ScaleAnimation scale=new ScaleAnimation(0, 1, 0, 1);
            scale.setDuration(3000);
            //delay(动画延迟):0~1f,当第一个动画执行到什么地方的时候,下一个动画开始执行
            //LayoutAnimationController controller=new LayoutAnimationController(scale, 0);
            LayoutAnimationController controller=new LayoutAnimationController(scale, 0.5f);
            //动画的执行顺序:ORDER_NORMAL(从上往 下);ORDER_RANDOM(随机执行);ORDER_REVERSE(从下往上)
           // controller.setOrder(LayoutAnimationController.ORDER_NORMAL);
            controller.setOrder(LayoutAnimationController.ORDER_REVERSE);
            layout.setLayoutAnimation(controller);
        }
    
    <pre name="code" class="java">//LayoutAnimationController controller=new LayoutAnimationController(scale, 0); //内部动画同时执行

    
    


    <pre name="code" class="java">LayoutAnimationController controller=new LayoutAnimationController(scale, 0.5f); //内部动画延时执行
    
    
    动画的执行顺序:ORDER_NORMAL(从上往 下):

    ORDER_REVERSE(从下往上)

  • 相关阅读:
    Oracle和SQLServer中实现跨库查询
    sqlserver中创建链接服务器
    无法从命令行或调试器启动服务,必须首先安装Windows服务(使用installutil.exe),然后用ServerExplorer、Windows服务器管理工具或NET START命令启动它
    Win8系统运行程序提示“占位程序接收到错误数据”的解决方法
    设计模式——简单工厂模式
    设计模式——单例模式
    设计模式——观察者模式
    三一集团提前批java面经
    form表单传到后端的数据乱码
    Failed to obtain the JDBC Connection + Access denied for user 'XXX'@'localhost' (using password: YES)
  • 原文地址:https://www.cnblogs.com/raphael5200/p/5114789.html
Copyright © 2011-2022 走看看