Android 翻译动画

Android 翻译动画,android,animation,translation,Android,Animation,Translation,我有一个网页,其中包括翻译动画。它只需单击按钮即可工作。此页面还包括一个列表视图。我的问题是,若列表视图中并没有任何项目,那个么在单击按钮时,翻译动画就不起作用。但是,如果列表视图只有一个项目,则动画可以正常工作。有人知道问题出在哪里吗? 下面是我的xml文件 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/t

我有一个网页,其中包括翻译动画。它只需单击按钮即可工作。此页面还包括一个列表视图。我的问题是,若列表视图中并没有任何项目,那个么在单击按钮时,翻译动画就不起作用。但是,如果列表视图只有一个项目,则动画可以正常工作。有人知道问题出在哪里吗? 下面是我的xml文件

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/backgnd_text_color">

//parent layout

<com.supportfiles.mypackage.PullToRefreshListView
        android:id="@+id/listView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:dividerHeight="1dp"
        android:divider="@color/orange_text"
        android:layout_alignParentLeft="true"/>

<include layout="@layout/my_sliding_layout"/>
</RelativeLayout> 
菜单是my_slide_layout.xml中的父相对布局


我在button click中调用SlidengAnimation()函数,但滑动动画仅在pull to refresh listview包含项目时才起作用。如果listview为空,则动画不起作用。提前感谢:)

您正在将动画应用于列表视图或父布局?不适用于列表视图。它是主布局中的一个相对布局,用于解决我们需要查看代码的问题,这些代码是用于动画的。我们猜不出原因。我已经发布了代码。请帮助我。提前谢谢
 public void slidingAnimation(int animateFromX, int animateToX, final int marginX){
    slide = new TranslateAnimation(animateFromX, animateToX, 0, 0);
    slide.setDuration(300);
    slide.setFillEnabled(true);
    slide.setAnimationListener(new AnimationListener() {
        public void onAnimationEnd(Animation animation) {       
            contentParams.setMargins(marginX, 0, 0, 0);         
            menu.setLayoutParams(contentParams);

        }

        public void onAnimationRepeat(Animation animation) { }
        public void onAnimationStart(Animation animation) { }
    });
    menu.startAnimation(slide);     

}