标签:android style blog http io color os ar 使用
1.默认情况下他,添加到viewGrop的子视图是直接显示出来的。有一个比较简单的方法可以为这个过程增加动画效果。
1 public class MainActivity extends Activity { 2 private ListView mListView; 3 @Override 4 protected void onCreate(Bundle savedInstanceState) { 5 super.onCreate(savedInstanceState); 6 setContentView(R.layout.activity_main); 7 mListView = (ListView) findViewById(R.id.listView); 8 mListView.setAdapter(new ArrayAdapter<String>(this, 9 android.R.layout.simple_list_item_1, Countries.COUNTRIES)); 10 AnimationSet set = new AnimationSet(true); 11 Animation alpha = new AlphaAnimation(0.0f, 1.0f); 12 alpha.setDuration(2000); 13 Animation translate = new TranslateAnimation( 14 Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 15 0.0f, Animation.RELATIVE_TO_SELF, -1.0f, 16 Animation.RELATIVE_TO_SELF, 0.0f); 17 translate.setDuration(1000); 18 set.addAnimation(alpha); 19 set.addAnimation(translate); 20 LayoutAnimationController controller = new LayoutAnimationController( 21 set); 22 mListView.setLayoutAnimation(controller); 23 } 24 }
activity_main.xml
1 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 xmlns:tools="http://schemas.android.com/tools" 3 android:layout_width="match_parent" 4 android:layout_height="match_parent" 5 android:orientation="vertical" 6 tools:context=".MainActivity" > 7 8 <ListView 9 android:id="@+id/listView" 10 android:layout_width="match_parent" 11 android:layout_height="match_parent" > 12 </ListView> 13 14 </LinearLayout>
HackSix 为ViewGroup的子视图添加悦目的动画效果
标签:android style blog http io color os ar 使用
原文地址:http://www.cnblogs.com/liangstudyhome/p/4057642.html