android 动态剪裁,android – 动画图像裁剪

Android动画API有很多麻烦.

我需要在屏幕(600px * 1024px)上从左下角到顶部动画图像(400px * 600px).此外,在动画开始时,大部分图像应位于屏幕之外.

这是我的布局:

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:background="@drawable/common_background">

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:scaleType="matrix"

android:src="@drawable/howto_throw_hand" />

活动的逻辑:

public class MyActivity extends Activity

{

ImageView hand;

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

hand = (ImageView)findViewById(R.id.hand);

}

@Override

public void onWindowFocusChanged(boolean hasFocus) {

//initial positioning

RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(

new ViewGroup.MarginLayoutParams(

RelativeLayout.LayoutParams.WRAP_CONTENT,

RelativeLayout.LayoutParams.WRAP_CONTENT

)

);

layoutParams.setMargins(400, 600, 0, 0);

hand.setLayoutParams(layoutParams);

//making animation

TranslateAnimation animation = new TranslateAnimation(

Animation.RELATIVE_TO_SELF, 0, Animation.ABSOLUTE, -100,

Animation.RELATIVE_TO_SELF, 0, Animation.ABSOLUTE, -1000

);

animation.setInterpolator(new LinearInterpolator());

animation.setDuration(3000);

//applying animation

hand.startAnimation(animation);

}

}

以及初始状态的屏幕截图:

问题是在动画过程中图像被裁剪为像这个视频:video with animation

我错过了很多时间,但未能解决问题=(

可以做些什么来解决这个问题?

先感谢您!

~~~~~~~~~~~~~~~~~~已解决~~~~~~~~~~~~~~~~~~

正如ben75所说:“问题是初始位置.当你进行TranslateAnimation时:图像不会移动:使用不同的平移重绘”和“动画只是翻译第一个裁剪图像.”

我怎么解决这个问题:

布局:

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:background="@drawable/common_background">

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:visibility="invisible"

android:src="@drawable/howto_throw_hand" />

活动的逻辑:

public class MyActivity extends Activity

{

ImageView hand;

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

hand = (ImageView)findViewById(R.id.hand);

}

@Override

public void onWindowFocusChanged(boolean hasFocus) {

//initial positioning — removed

//making animation

TranslateAnimation animation = new TranslateAnimation(400, 300, 600, 0);

animation.setInterpolator(new LinearInterpolator());

animation.setDuration(3000);

//applying animation

hand.startAnimation(animation);

}

}

答对了!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值