我需要在屏幕外放置一个ImageView,以便为它制作动画,但我无法使其正常工作。我需要支持api 9+,我尝试了以下代码:
ImageView camion = (ImageView) findViewById(R.id.camion);
int amountOffscreen = (int)(camion.getWidth() * 0.8); /* or whatever */
boolean offscreen = true; /* true or false */
int xOffset = (offscreen) ? amountOffscreen : 0;
RelativeLayout.LayoutParams rlParams =
(RelativeLayout.LayoutParams)camion.getLayoutParams();
rlParams.setMargins(-1*xOffset, 0, xOffset, 0);
camion.setLayoutParams(rlParams);
但ImageView框架保持不变。