我有这个元素:
<View
android:id="@+id/cameraProgressBar"
android:layout_width="1dp"
android:layout_height="15dp"
android:background = "#ffffff"
android:layout_alignParentBottom="true"/>
和这个动画代码:
mProgressBar = findViewById(R.id.cameraProgressBar);
private void showGlassProgressBar(final Runnable onAnimationEnd) {
float screenWidth = myManager.GetScreenWidth();
ScaleAnimation scaleAnim = new ScaleAnimation(1F, screenWidth, // Start and end values for the X
// axis
// scaling
1F, 1F, // Start and end values for the Y axis scaling
Animation.RELATIVE_TO_SELF, 1f, // Pivot point of X scaling
Animation.RELATIVE_TO_SELF, 0f); // Pivot point of Y scaling
scaleAnim.setFillAfter(true); // Needed to keep the result of the animation
scaleAnim.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animation animation) {
AppService.Post(onAnimationEnd);
}
});
scaleAnim.setInterpolator(new LinearInterpolator());
scaleAnim.setDuration(3 * 1000);
mProgressBar.startAnimation(scaleAnim);
}
我想将一个dp点延长到一个完整的行(x asix)
但是动画结束了,没有看到任何内容。
答案 0 :(得分:0)
签名是X-scale(开始,结束)和Y-scale。
表示没有绝对X尺寸screenWidth
更好的改变:
ScaleAnimation scaleAnim = new ScaleAnimation(1F, screenWidth,
1F, 1F,
Animation.RELATIVE_TO_SELF, 1f, // Pivot point of X scaling
Animation.RELATIVE_TO_SELF, 0f); // Pivot point of Y scaling
使用:
ScaleAnimation scaleAnim = new ScaleAnimation((float) 0.0, (float) 1.0,
1F, 1F,
Animation.RELATIVE_TO_SELF, 0f, // Pivot point of X scaling
Animation.RELATIVE_TO_SELF, 0f); // Pivot point of Y scaling