<bdo id='Z5vEg'></bdo><ul id='Z5vEg'></ul>

    <i id='Z5vEg'><tr id='Z5vEg'><dt id='Z5vEg'><q id='Z5vEg'><span id='Z5vEg'><b id='Z5vEg'><form id='Z5vEg'><ins id='Z5vEg'></ins><ul id='Z5vEg'></ul><sub id='Z5vEg'></sub></form><legend id='Z5vEg'></legend><bdo id='Z5vEg'><pre id='Z5vEg'><center id='Z5vEg'></center></pre></bdo></b><th id='Z5vEg'></th></span></q></dt></tr></i><div id='Z5vEg'><tfoot id='Z5vEg'></tfoot><dl id='Z5vEg'><fieldset id='Z5vEg'></fieldset></dl></div>
    <legend id='Z5vEg'><style id='Z5vEg'><dir id='Z5vEg'><q id='Z5vEg'></q></dir></style></legend>
    <tfoot id='Z5vEg'></tfoot>
  1. <small id='Z5vEg'></small><noframes id='Z5vEg'>

    1. 同时将一个动画应用于多个视图

      时间:2023-05-18
      <legend id='uGXV2'><style id='uGXV2'><dir id='uGXV2'><q id='uGXV2'></q></dir></style></legend>

      • <i id='uGXV2'><tr id='uGXV2'><dt id='uGXV2'><q id='uGXV2'><span id='uGXV2'><b id='uGXV2'><form id='uGXV2'><ins id='uGXV2'></ins><ul id='uGXV2'></ul><sub id='uGXV2'></sub></form><legend id='uGXV2'></legend><bdo id='uGXV2'><pre id='uGXV2'><center id='uGXV2'></center></pre></bdo></b><th id='uGXV2'></th></span></q></dt></tr></i><div id='uGXV2'><tfoot id='uGXV2'></tfoot><dl id='uGXV2'><fieldset id='uGXV2'></fieldset></dl></div>
          <tbody id='uGXV2'></tbody>
          <tfoot id='uGXV2'></tfoot>
            <bdo id='uGXV2'></bdo><ul id='uGXV2'></ul>

              <small id='uGXV2'></small><noframes id='uGXV2'>

              1. 本文介绍了同时将一个动画应用于多个视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                所以我想同时旋转几个视图,所有视图都使用相同的旋转规范.问题是由于某种原因,第二个元素的旋转作用不同.显然,这与动画对象在这两行代码之间实际改变状态有关.显然我可以创建一个单独的动画对象并应用它,但我觉得有一种更简单的方法(我有大约 15 个视图)

                So Id like to rotate a handful of views all at the same time, all using the same rotation specs. The issue is that for some reason the rotation acts differently for the second element. Apparently this has to do with the animation object actually changing state in between those two lines of code. Obviously I could just create a seperate Animation object and apply it, but I feel like there is an easier way (I have about 15 views)

                仅正确旋转第一个视图:

                Rotates only the first view correctly:

                Animation rotateAnim = AnimationUtils.loadAnimation(this, R.anim.rotationtoportrait);
                target.startAnimation(rotateAnim);
                lightBtn.startAnimation(rotateAnim);
                

                两个都正确旋转

                Animation rotateAnim = AnimationUtils.loadAnimation(this, R.anim.rotationtoportrait);
                Animation rotateAnim2 = AnimationUtils.loadAnimation(this, R.anim.rotationtoportrait);
                target.startAnimation(rotateAnim);
                lightBtn.startAnimation(rotateAnim2);
                

                XML:

                <?xml version="1.0" encoding="utf-8"?>
                <rotate
                    xmlns:android="http://schemas.android.com/apk/res/android"
                    android:fromDegrees="-90"
                    android:toDegrees="0"
                    android:pivotX="50%"
                    android:pivotY="50%"
                    android:duration="500" android:fillAfter="true">
                

                有人有想法么?

                推荐答案

                所以我想这是不可能的,所以我创建了一个辅助方法来将相同的动画应用于视图列表:

                So I guess this just isn't possible, so I created a helper method to just apply the same animation to a list of views:

                public void doRotations(ArrayList<View> views, int start, int end, int xprop, float xscale, int yprop, float yscale, int duration, Boolean fillAfter){
                
                    for(int i = 0; i < views.size(); i++){
                        RotateAnimation temp = new RotateAnimation(start, end, xprop, xscale, yprop, yscale);
                        temp.setDuration(duration);
                        temp.setFillAfter(fillAfter);
                        views.get(i).startAnimation(temp);
                    }
                }
                

                绝对是一个 hack,但我想这就是我现在能做的全部

                Definitely a hack, but I guess thats all I'm able to do right now

                这篇关于同时将一个动画应用于多个视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何提高android中的旋转速度? 下一篇:旋转自定义 UITableViewCell

                相关文章

                <small id='dGdCE'></small><noframes id='dGdCE'>

                  <bdo id='dGdCE'></bdo><ul id='dGdCE'></ul>
              2. <i id='dGdCE'><tr id='dGdCE'><dt id='dGdCE'><q id='dGdCE'><span id='dGdCE'><b id='dGdCE'><form id='dGdCE'><ins id='dGdCE'></ins><ul id='dGdCE'></ul><sub id='dGdCE'></sub></form><legend id='dGdCE'></legend><bdo id='dGdCE'><pre id='dGdCE'><center id='dGdCE'></center></pre></bdo></b><th id='dGdCE'></th></span></q></dt></tr></i><div id='dGdCE'><tfoot id='dGdCE'></tfoot><dl id='dGdCE'><fieldset id='dGdCE'></fieldset></dl></div>
                <tfoot id='dGdCE'></tfoot>

                  1. <legend id='dGdCE'><style id='dGdCE'><dir id='dGdCE'><q id='dGdCE'></q></dir></style></legend>