一个爱奔跑的胖子 2015-05-18 04:56 采纳率: 0%
浏览 1582
已结题

andrid平移动画俩动画切花会卡一下

img_ayout_1和img_ayout_2是俩布局

    public Runnable runnable = new Runnable() {
        @Override
        public void run() {
            // TODO Auto-generated method stub
            //俩个动画
            AnimationSet animationSet1 = new AnimationSet(true);
            AnimationSet animationSet2 = new AnimationSet(true);
            //设置imageView2 为可见
            img_ayout_2.setVisibility(0);
            TranslateAnimation ta = new TranslateAnimation(
                    Animation.RELATIVE_TO_SELF, -1f, 
                    Animation.RELATIVE_TO_SELF,0f,
                    Animation.RELATIVE_TO_SELF, 0f,
                    Animation.RELATIVE_TO_SELF, 0f);
            //设置动画持续时间
            ta.setDuration(10000);
            //放入动画
            animationSet1.addAnimation(ta);
            //动画充满
            animationSet1.setFillAfter(true);

            ta = new TranslateAnimation(
                    Animation.RELATIVE_TO_SELF,0f,
                    Animation.RELATIVE_TO_SELF, 1.0f,
                    Animation.RELATIVE_TO_SELF,0f, 
                    Animation.RELATIVE_TO_SELF, 0f);
            ta.setDuration(10000);
            animationSet2.addAnimation(ta);
            animationSet2.setFillAfter(true);
            // 开始执行 

                img_ayout_1.startAnimation(animationSet1);
                img_ayout_2.startAnimation(animationSet2);


            if (juage){

                handler.postDelayed(runnable,8000); 
                }
            }
    };

调用:handler.postDelayed(runnable, 0);

问题:在切换下一轮动画的时候俩布局间距会变大

  • 写回答

1条回答 默认 最新

  • 一个爱奔跑的胖子 2015-05-18 05:27
    关注

    布局:

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:layout_weight="0.14"
            android:orientation="vertical" >
    
             <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:orientation="vertical" 
              android:id="@+id/img_Layout_1"
            >
            <ImageView
    
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/line1" />
    
            <ImageView
    
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/line2" />
        </RelativeLayout>
    
              <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:id="@+id/img_Layout_2"
            android:orientation="vertical" >
    
    
            <ImageView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/line1" />
    
            <ImageView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/line2" />
        </RelativeLayout>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥30 最小化遗憾贪心算法上界
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝