After apply this animation to my (chield)RelativeLayout, my backgroud image has the good size but my Layout seem to continue to take to much place on my Page (parent)RelativeLayout. Some idea?
将此动画应用于我的(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>
I have add like you propose me a listener to fit my layout with this command :
我添加了像你建议我一个监听器,以适应我的布局与此命令:
params.width = (int) getResources().getDimension(R.dimen.size_width);
how can I know the "size_width" that I have to put? Like I ask to scale from 1.0 to 0.2 and finaly put android:layout_width="300dp", I have imagine that "size_width" have to take 60dp (300 * 0.2) but it's very to small compare to size after the animation.
我怎么知道我要放的“size_width”?就像我要求从1.0扩展到0.2并最终放入android:layout_width =“300dp”,我想象“size_width”必须占用60dp(300 * 0.2),但它与动画后的大小相比非常小。
3 个解决方案
#1
0
Use animation listener like this
像这样使用动画监听器
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) {
}
});
#2
0
I'm not sure if i understand your problem correctly but you can add an animation listener to your animation:
我不确定我是否正确理解您的问题,但您可以为动画添加动画监听器:
yourAnimation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
And in onAnimationEnd try to invalidate your view.
并在onAnimationEnd尝试使您的视图无效。
yourView.invalidate();
#3
0
Finally, I just stop to use the param android:fillAfter="true", he seem to don't change the size of the layout... I just change size of my layout with onAnimationEnd.
最后,我只是停止使用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);
#1
0
Use animation listener like this
像这样使用动画监听器
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) {
}
});
#2
0
I'm not sure if i understand your problem correctly but you can add an animation listener to your animation:
我不确定我是否正确理解您的问题,但您可以为动画添加动画监听器:
yourAnimation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
And in onAnimationEnd try to invalidate your view.
并在onAnimationEnd尝试使您的视图无效。
yourView.invalidate();
#3
0
Finally, I just stop to use the param android:fillAfter="true", he seem to don't change the size of the layout... I just change size of my layout with onAnimationEnd.
最后,我只是停止使用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);