在将这个动画应用到我的(chield)RelativeLayout之后,我的背景图像具有很好的大小,但是我的布局似乎继续在我的页面(父)RelativeLayout上占据很大的位置。什么主意?
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true" >
<scale
android:fromXScale="1.0"
android:fromYScale="1.0"
android:toXScale="0.2"
android:toYScale="0.2"
android:duration="700"
>
</scale>
</set>
<RelativeLayout ...>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/chieldLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bigImage"
>
<Button
style="@style/boutonBrun"
android:id="@+id/btPanier"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/full22lightgreen"
/>
</RelativeLayout>
</RelativeLayout>我添加了一个侦听器(就像您建议的那样),使我的布局符合以下命令:
params.width = (int) getResources().getDimension(R.dimen.size_width);我怎么知道我要放的"size_width“呢?就像我要求从1.0扩展到0.2,最后将android:layout_width=放在“300‘s”,我想象"size_width“必须使用60’s (300 * 0.2),但是与动画之后的大小相比,这是非常小的。
发布于 2015-04-10 10:15:23
像这样使用动画监听器
animation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
// set height for your relative layout here
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});发布于 2015-04-10 10:16:31
我不确定我是否正确地理解了您的问题,但是您可以在动画中添加一个动画侦听器:
yourAnimation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});在onAnimationEnd中,尝试使您的视图无效。
yourView.invalidate();发布于 2015-04-10 23:02:41
最后,我只是停下来使用param android:fillAfter="true",他似乎没有改变布局的大小.我只是用onAnimationEnd来改变布局的大小。
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) myRelativeLayout.getLayoutParams();
params.width = (int) getResources().getDimension(R.dimen.little_house_width);
params.height = (int) getResources().getDimension(R.dimen.little_house_height);
setLayoutParams(params);https://stackoverflow.com/questions/29558784
复制相似问题