【问题标题】:How to move view permanently in Android如何在 Android 中永久移动视图
【发布时间】:2015-07-01 16:15:03
【问题描述】:

假设我有一个视图,我想使用setTranslationY 方法将其向上移动。

View view = findViewById(R.id.mView);
view.setTranslationY(-10.0f);

视图确实向上移动了,但我发现它仍然占据原始位置。我怎样才能将视图永久移动到最终位置。我也找到了类似的解决方案但不起作用。Android translate animation - permanently move View to new position using AnimationListener

【问题讨论】:

    标签: android view


    【解决方案1】:

    改为使用和修改LayoutParams

    【讨论】:

      【解决方案2】:

      您可以使用一个名为 NineOldAndroids 的库来在所有版本的平台上使用 Honeycomb 动画 API 回到 1.0! (http://nineoldandroids.com)

      试试这个...

      ViewHelper.setTranslationX(view, 50f);

      只有您使用 ViewHelper 类中的静态方法并传递视图对象和您想要设置的值。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-10-01
        • 1970-01-01
        • 2012-11-05
        • 2019-11-04
        • 2017-07-04
        • 2012-07-10
        • 1970-01-01
        相关资源
        最近更新 更多