0

我在我的应用中应用了一个否定toXDeltaTranslateAnimation当我滚动到列表时这会导致一个错误,因为在这个移动中还有另一个列表。

你可以在这个屏幕截图中看到我的问题在此处输入图像描述

这是我的橙色列表的 XML

<LinearLayout
    android:id="@+id/ll_list_ghm"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:background="@drawable/panel_ghm"
    android:orientation="vertical"
    android:paddingLeft="30dip"
    android:paddingRight="20dip"
    android:paddingTop="40dip" >

    <ListView
        android:id="@+id/lv_list_ghm"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
    </ListView>
</LinearLayout>

我将翻译应用于LinearLayout

ll_list_ghm.startAnimation(expend(500, true));
private Animation expend(int anim_ms, boolean is_ghm) {
    Animation collapse = new TranslateAnimation(400, -20, 0, 0);
    collapse.setDuration(anim_ms);
    collapse.setFillAfter(true);
    return collapse;
}

toXDelta等于 0 或正整数时没有问题。有人遇到过这个错误吗?

感谢您阅读和关注 ma 问题。

4

1 回答 1

0

我找到了另一种解决方案,即在代码上设置负边距。

RelativeLayout.LayoutParams lp_list_ghm = new RelativeLayout.LayoutParams(metrics.widthPixels / 4, LayoutParams.FILL_PARENT);
lp_list_ghm.addRule(RelativeLayout.RIGHT_OF, R.id.ll_list_cmd);
lp_list_ghm.setMargins(-20, 0, 0, 0);
ll_list_ghm.setLayoutParams(lp_list_ghm);

但是,如果您有其他解决方案,我很感兴趣:)

于 2012-03-15T08:06:09.387 回答