将图像由左到右的android图像、左到右、android

2023-09-12 03:15:27 作者:比你爸有样〆

我只是想转换使用的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..

解决方案 超乎想像 图解Android L到底给力在哪

    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.