这篇文章将介绍listView 代码自定义布局动画和布局动画清单属性配置
1:listView 代码自定义布局动画
public class PlaceHolderFragment3 extends ListFragment {
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
ArrayAdapter adapter=new ArrayAdapter<String>(getActivity(),android.R.layout.simple_list_item_1,new String[]{"xx","yy","jj"});
setListAdapter(adapter);
ScaleAnimation sa=new ScaleAnimation(0,1,0,1);
sa.setDuration(5000);
getListView().setLayoutAnimation(new LayoutAnimationController(sa,0.5f));
}
}
1:xml布局动画
容器有一个属性,
layoutAnimation
比如listview :<?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="match_parent"
android:orientation="vertical">
<ListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layoutAnimation="@anim/listview_anim"></ListView>
</LinearLayout>
android:layoutAnimation=""引用的不是基本动画(scale,roate....),而是layoutAnimation
<?xml version="1.0" encoding="UTF-8"?>
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:animation="@anim/scale_0_1"
android:delay="0.5"
/>
sacle动画的资源配置,就不用我贴出来了吧