【发布时间】:2014-03-25 14:00:15
【问题描述】:
我在这个相对布局中有一个相对布局(父视图)和一个按钮(子视图)。我在父视图上应用缩放动画以便向下滑动和向上滑动动画。但是当缩放动画应用于父视图它的子视图也缩放。有什么理由阻止孩子动画 这是我的布局代码
<RelativeLayout
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_marginTop="80px"
android:id="@+id/txt_help_gest"
android:background="#111111"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/test"
android:clickable="true"
android:onClick="toggle_contents1"
android:text="title" />
</RelativeLayout>
我的比例动画代码
<?xml version="1.0" encoding="utf-8"?>
<scale
android:duration="500"
android:fromXScale="1.0"
android:fromYScale="0.0"
android:interpolator="@android:anim/linear_interpolator"
android:toXScale="1.0"
android:toYScale="0.5" />
缩放到 0.5 意味着我希望我的视图从原始大小缩放到一半,但它的孩子也变成了一半
我的java代码
public static void slide_down(Context ctx, View v) {
Animation a = AnimationUtils.loadAnimation(ctx, R.anim.slidedown);
a.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) {
// TODO Auto-generated method stub
b.clearAnimation();
}
});
if (a != null) {
a.reset();
if (v != null) {
v.clearAnimation();
v.startAnimation(a);
}
}
}
【问题讨论】:
标签: android animation view scale