我们大家都看过动画效果的文章,但今天的这一片我们主要讲的就是 Fragment 动画效果。
我们怎么样才能实现那,我们一共分为了四个步骤,这四个步骤就是主布局(main.xml)实
现 、 FirstFragment 布 局 (first_fragment.xml) 实 现 、 SecondFragment 布 局
(second_fragment.xml)实现、主 Activity 实现。那么我们就根据这四个步骤,我们自
己动手来操作一下。那么我们先来看看第一个步骤,实现 main 的代码:
Java 代码:
1
2 <?xml version="1.0" encoding="utf-8"?>
3 <LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android"
4 android:orientation = "vertical"
5 android:layout_width = "fill_parent"
6 android:layout_height = "fill_parent"
7 >
8
9 <LinearLayout
10 android:orientation = "horizontal"
11 android:padding = "4dip"
12 android:gravity = "center_vertical"
13 android:layout_weight = "1"
14 android:layout_width = "match_parent"
15 android:layout_height = "wrap_content"
16 >
17
18 <Button
19 android:id = "@+id/firstButton"
20 android:layout_width = "wrap_content"
21 android:layout_height = "wrap_content"
22 android:text = "Hide"
23 />
24
25 <fragment
26 android:name = "com.flora.FragmentAnimationActivity$FirstFragment"
27 android:id = "@+id/firstFragment"
28 android:layout_weight = "1"
29 android:layout_width = "0px"
30 android:layout_height = "wrap_content"
31 />