展开/折叠ExpandableListView的项目时,是否可以有一个很好的上下滑动效果?
如果有,怎么样?
提前致谢.
好吧,我正在尝试做一个合适的下滑动画.向下滑动的视图应该将所有视图推向一个平滑的运动,并且当它向上滑动时,所有视图应该在一个平滑的运动中跟随.
我试过的:在代码中:
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) 有没有办法在Android中打开可扩展列表时添加动画?我想要它,以便当用户点击可扩展列表时,它有一个动画/效果,就像我打开一个滑动抽屉.
它移动缓慢直到完全打开.