GIthub开源项目实现翻页效果(FlipView)

来源:互联网 发布:vscode 快捷键 编辑:程序博客网 时间:2024/05/16 06:13

Github项目地址:https://github.com/openaphid/android-flip

效果图一:

                                                                                       screenshot

                                                                                                                                                                                                                                                                                     

效果图二:                                                               

                          screenshot

                                                                                                                                                                                                                                                                                 


先看一下,使用是多么简单,首先有两个布局。


布局一:

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"              android:layout_width="fill_parent"              android:layout_height="fill_parent"              android:orientation="vertical"              android:background="@android:color/white"><TextView android:layout_width="fill_parent" android:layout_height="wrap_content"          android:textSize="24dip"          android:text="@string/first_page_title"          android:background="@android:color/white"          android:textColor="@android:color/black" android:textStyle="bold"/><TextView android:layout_width="fill_parent" android:layout_height="wrap_content"          android:layout_weight="1.0"          android:layout_marginTop="8dp"          android:textSize="16dp"          android:background="@android:color/white"          android:textColor="@android:color/black"          android:text="@string/first_page_description"/><ImageView android:layout_width="fill_parent" android:layout_height="wrap_content"           android:background="@android:color/white"           android:src="@drawable/aphid_logo"/></LinearLayout>


布局二:

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"              android:layout_width="fill_parent"              android:layout_height="fill_parent"              android:orientation="vertical"              android:background="@android:color/white"><TextView android:layout_width="fill_parent" android:layout_height="wrap_content"          android:textSize="24dip"          android:text="@string/second_page_title"          android:background="@android:color/white"          android:textColor="@android:color/black"          android:shadowColor="@android:color/background_light"          android:shadowDx="2"          android:shadowRadius="5"android:textStyle="bold"/><TextView android:layout_width="fill_parent" android:layout_height="wrap_content"          android:layout_weight="1.0"          android:layout_marginTop="8dp"          android:textSize="16dp"          android:background="@android:color/white"          android:textColor="@android:color/black"          android:text="@string/second_page_description"/><ImageView android:layout_width="fill_parent" android:layout_height="wrap_content"           android:background="@android:color/white"           android:src="@drawable/aphid_kid"/></LinearLayout>


然后看在MainActivity里面是如何使用的

     <span style="font-family: Arial, Helvetica, sans-serif;">private FlipViewGroup contentView;//声明ViewGroup</span>
/** * Called when the activity is first created. */@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setTitle(R.string.activity_title);contentView = new FlipViewGroup(this);//初始化ViewGroup//将布局添加到ViewGroup中contentView.addFlipView(View.inflate(this, R.layout.second_page, null));contentView.addFlipView(View.inflate(this, R.layout.first_page, null));setContentView(contentView);contentView.startFlipping(); //make the first_page view flipping}



1 0
原创粉丝点击