首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >规模化动画后如何适应RelativeLayout

规模化动画后如何适应RelativeLayout
EN

Stack Overflow用户
提问于 2015-04-10 10:11:02
回答 3查看 633关注 0票数 1

在将这个动画应用到我的(chield)RelativeLayout之后,我的背景图像具有很好的大小,但是我的布局似乎继续在我的页面(父)RelativeLayout上占据很大的位置。什么主意?

代码语言:javascript
复制
<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>

我添加了一个侦听器(就像您建议的那样),使我的布局符合以下命令:

代码语言:javascript
复制
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),但是与动画之后的大小相比,这是非常小的。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2015-04-10 10:15:23

像这样使用动画监听器

代码语言:javascript
复制
    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) {

        }
    });
票数 0
EN

Stack Overflow用户

发布于 2015-04-10 10:16:31

我不确定我是否正确地理解了您的问题,但是您可以在动画中添加一个动画侦听器:

代码语言:javascript
复制
yourAnimation.setAnimationListener(new Animation.AnimationListener() {
                     @Override
                     public void onAnimationStart(Animation animation) {

                     }

                     @Override
                     public void onAnimationEnd(Animation animation) {

                     }

                     @Override
                     public void onAnimationRepeat(Animation animation) {

                     }
                  });

在onAnimationEnd中,尝试使您的视图无效。

代码语言:javascript
复制
yourView.invalidate();
票数 0
EN

Stack Overflow用户

发布于 2015-04-10 23:02:41

最后,我只是停下来使用param android:fillAfter="true",他似乎没有改变布局的大小.我只是用onAnimationEnd来改变布局的大小。

代码语言:javascript
复制
  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);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29558784

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档