【问题标题】:Why does my buttons lag when they move?为什么我的按钮在移动时会滞后?
【发布时间】:2017-09-30 15:29:38
【问题描述】:

现在在我的应用程序中,我有一个主按钮。如果单击它,则会出现另外两个按钮,如果再次单击此主按钮,它们就会消失。 我还让这两个按钮移动,而不是让它们在没有动画的情况下出现。这里的问题是,每当它们移动时,它们就会滞后。

这是主要的方法:

public void buttonClickAppear(View view) {
        animMove = loadAnimation(this, R.anim.anim_translate);
        if (!reportesState) {
            playas.startAnimation(animMove);
            playas.setVisibility(View.VISIBLE);
            res.startAnimation(animMove);
            res.setVisibility(View.VISIBLE);
            reportesState = true;
        } else {
            playas.setVisibility(View.GONE);
            res.setVisibility(View.GONE);
            reportesState = false;
        }
    }

这是动画:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/linear_interpolator">
    <translate
        android:fromXDelta="100"
        android:toXDelta="100"
        android:duration="80"
        />

</set>

我该怎么办?问题可能是什么?可能是动画的xml代码不对,不知道……

【问题讨论】:

    标签: android dictionary button move lag


    【解决方案1】:

    您不需要android:toXDelta="100" 行。它导致了延迟。

    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/linear_interpolator">
        <translate
            android:duration="80"
            android:fromXDelta="100"/>
    </set>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-01-15
      • 1970-01-01
      • 2017-02-27
      • 2018-03-10
      • 1970-01-01
      • 2017-05-18
      • 1970-01-01
      相关资源
      最近更新 更多