码迷,mamicode.com
首页 > 其他好文 > 详细

画图类

时间:2015-07-23 17:36:20      阅读:93      评论:0      收藏:0      [点我收藏+]

标签:

 1 package cativity.cyq.layoutanimation;
 2 
 3 import android.support.v7.app.ActionBarActivity;
 4 import android.support.v4.app.Fragment;
 5 import android.os.Bundle;
 6 import android.view.LayoutInflater;
 7 import android.view.Menu;
 8 import android.view.MenuItem;
 9 import android.view.View;
10 import android.view.ViewGroup;
11 import android.view.animation.LayoutAnimationController;
12 import android.view.animation.ScaleAnimation;
13 import android.widget.LinearLayout;
14 
15 
16 public class MainActivity extends ActionBarActivity {
17 
18     @Override
19     protected void onCreate(Bundle savedInstanceState) {
20         super.onCreate(savedInstanceState);
21         setContentView(R.layout.activity_main);
22         if (savedInstanceState == null) {
23             getSupportFragmentManager().beginTransaction().addToBackStack(null)
24                     .add(R.id.container, new PlaceholderFragment())
25                     .commit();
26         }
27     }
28 
29     public static class PlaceholderFragment extends Fragment {
30 
31         public PlaceholderFragment() {
32         }
33 
34         @Override
35         public View onCreateView(LayoutInflater inflater, ViewGroup container,
36                                  Bundle savedInstanceState) {
37             LinearLayout rootView = (LinearLayout) inflater.inflate(R.layout.fragment_main, container, false);
38             ScaleAnimation sAnimatio = new ScaleAnimation(0, 1, 0, 1);
39             sAnimatio.setDuration(200);
40             //使用布局动画管理器
41 
42             LayoutAnimationController layoutAniController = new LayoutAnimationController(sAnimatio, 0.9f);
43             rootView.setLayoutAnimation(layoutAniController);
44 
45             rootView.findViewById(R.id.skipto).setOnClickListener(new View.OnClickListener() {
46                 @Override
47                 public void onClick(View v) {
48                     getFragmentManager().beginTransaction().addToBackStack(null)
49                             .replace(R.id.container, new MyFragment())
50                             .commit();
51 
52 
53                 }
54             });
55 
56             return rootView;
57         }
58     }
59 
60     @Override
61     public boolean onCreateOptionsMenu(Menu menu) {
62         getMenuInflater().inflate(R.menu.menu_main, menu);
63         return true;
64     }
65 
66     @Override
67     public boolean onOptionsItemSelected(MenuItem item) {
68         int id = item.getItemId();
69         if (id == R.id.action_settings) {
70             return true;
71         }
72 
73         return super.onOptionsItemSelected(item);
74     }
75 
76 
77 }

 

画图类

标签:

原文地址:http://www.cnblogs.com/chenyangqi/p/4670925.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!