将图像由左到右的android [英] Move image from left to right in android

查看:88
本文介绍了将图像由左到右的android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想转换使用的Andr​​oid animation.I'm新的Andr​​oid animation.How我能做到这一点左至右仿真器的图像。?编码是多少AP preciated.Thanks ..

解决方案

  LL =新的LinearLayout(本);
    ll.setLayoutParams(新的LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
    ll.setOrientation(LinearLayout.VERTICAL);

    电视=新的TextView(本);
    tv.setText(动画);

    moveLefttoRight =新TranslateAnimation(0,200,0,0);
    moveLefttoRight.setDuration(1000);
    moveLefttoRight.setFillAfter(真正的);

    按钮=新的按钮(这一点);
    button.setLayoutParams(新的LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
    button.setText(pressMe);
    button.setOnClickListener(新OnClickListener(){

        公共无效的onClick(视图v){
            tv.startAnimation(moveLefttoRight);
        }

    });

    ll.addView(电视);
    ll.addView(按钮);
    的setContentView(Ⅱ);
 

是这样做的一种方式。

i just wanna translate an image from left to right on emulator using android animation.I'm new to android animation.How could i do that.?coding is much appreciated.Thanks..

解决方案

    ll = new LinearLayout(this);
    ll.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    ll.setOrientation(LinearLayout.VERTICAL);

    tv = new TextView(this);
    tv.setText("Animation");

    moveLefttoRight = new TranslateAnimation(0, 200, 0, 0);
    moveLefttoRight.setDuration(1000);
    moveLefttoRight.setFillAfter(true);

    button = new Button(this);
    button.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    button.setText("PressMe");
    button.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            tv.startAnimation(moveLefttoRight);
        }

    });

    ll.addView(tv);
    ll.addView(button);
    setContentView(ll);

is one way of doing it.

这篇关于将图像由左到右的android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆