相关疑难解决方法(0)

在折叠/展开时动画化expandablelistview的子项

我正在尝试在expandablelistview中为我的子视图设置动画.我希望子视图在展开组时从顶部向下滑动,并在折叠组时从底部滑动到顶部.我已经看过几种方法(动画视图组或子视图),但似乎没有一种方法可以很好地工作,或者我做得不对.

我已经从BaseExpandableListAdapter扩展了一个类来创建我自己的自定义适配器.我还有我在getChildView和getGroupView方法中膨胀的组/子项的自定义(xml)视图.

我只希望当前崩溃/扩展的小组为其孩子制作动画.谁能指出我正确的方向?如果您需要更多信息或代码,请告诉我们!

问候,伊沃

animation android expandablelistview

16
推荐指数
2
解决办法
1万
查看次数

Android动画下拉/向上视图正确

好吧,我正在尝试做一个合适的下滑动画.向下滑动的视图应该将所有视图推向一个平滑的运动,并且当它向上滑动时,所有视图应该在一个平滑的运动中跟随.

我试过的:在代码中:

LinearLayout lin = (LinearLayout)findViewById(R.id.user_list_container);
                setLayoutAnimSlidedownfromtop(lin, this);
                lin.addView(getLayoutInflater().inflate(R.layout.user_panel,null),0);
Run Code Online (Sandbox Code Playgroud)

和:

public static void setLayoutAnimSlidedownfromtop(ViewGroup panel, Context ctx) {

      AnimationSet set = new AnimationSet(true);

      Animation animation = new AlphaAnimation(0.0f, 1.0f);
      animation.setDuration(100);
      set.addAnimation(animation);

      animation = new TranslateAnimation(
          Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
          Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f
      );
      animation.setDuration(500);
      set.addAnimation(animation);

      LayoutAnimationController controller =
          new LayoutAnimationController(set, 0.25f);
      panel.setLayoutAnimation(controller);

}
Run Code Online (Sandbox Code Playgroud)

我的user_panel.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="40dp"
    android:orientation="vertical" >
    <ImageView 
        android:layout_alignParentLeft="true"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:src="@drawable/icon" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

主要xml的顶部:

<LinearLayout
        android:id="@+id/user_list_container"
        android:layout_alignParentTop="true"
        android:orientation="vertical" 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>
    <LinearLayout …
Run Code Online (Sandbox Code Playgroud)

animation android view

16
推荐指数
2
解决办法
4万
查看次数

LayoutAnimationController可以仅为指定的视图设置动画

是否有可能以LayoutAnimationController这样的方式覆盖Android :只有View我在其中指定的某些子项ViewGroup才会生成动画?我的目标是根据当前状态选择任意一组子视图,Activity并在同一时间使用相同的动画为它们设置动画,然后在以后选择不同的任意子视图集并执行相同的操作.我希望能够持续这样做直到Activity完成运行.

到目前为止,我已经查看并驳回了几个选项:

  1. startAnimation(Animation)单独调用特定子视图,但不能保证它们将在完全相同的时间开始和结束,特别是如果任意集中的视图数量很大.
  2. 覆盖LayoutAnimationController.getAnimationForView()似乎是最简单的方法,但方法是最终的,不能被覆盖.

我一直在摸不着头脑,并且认为我会给Stack Overflow一个机会.

android layout-animation

3
推荐指数
1
解决办法
2048
查看次数