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

news/2025/2/26 5:04:55

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.
	 */
	@Override
	public 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
	}




http://www.niftyadmin.cn/n/4581878.html

相关文章

i510300h和i710750h的区别 哪个好

酷睿i7-10750H&#xff0c;显然是bai酷睿i7-9750H的继任者、未来高端游戏du本的标配&#xff0c;继续6核心zhi12线程&#xff0c;基准频率还是2.6GHz&#xff0c;但是最dao高睿频频率从4.6GHz大幅提升至5.0GHz。 i510300h和i710750h 哪个用来搭配笔记本更好用&#xff1f;看完你…

面向对象css oocss

1、概念oocss&#xff1a;将页面可重用元素抽象成一个类&#xff0c;用class加以描述&#xff0c;而对其他对应的HTML即可看成是此类的一个实例2、作用1、加强代码复用以便方便维护2、减小css体积3、提升渲染效率4、组件库思想、栅格布局可共用、减少选择器、方便拓展3、注意事…

i510300h和i5 9300h的区别 哪个好

1、5-9300H&#xff1a;内存类型为DDR4 2666MHz&#xff0c;LPDDR3 2133MHz。 2、i5-10300H&#xff1a;内存类型为DDR4 2933MHz。 哪一款笔记本值得购买?懂笔记本的人这样选! https://diannao.jd.com 二、集成显卡不同 1、I5-9300H&#xff1a;集成显卡为英特尔 超核芯显卡…

gradle dsl method not found : 'android()'

每当我们从GitHub上下载项目导入到自己Android Studio中总会报出这种错误&#xff0c;现总结一下解决方法。 第一&#xff1a;改变一下Compile sdk version 和Build 工具 Try Again。 第二&#xff1a;如果第一种不行&#xff0c;则删除外层&#xff08;Top-level&#xff…

Java技术自学规划(学习路线图、书籍、视频总结)

Java的火爆袭来&#xff0c;吸引了大批的初学者涉猎&#xff0c;想入行Java&#xff0c;却苦于自己没有基础&#xff0c;担心学不好。我告诉你&#xff0c;这些担心都是浮云&#xff0c;你只是惧怕走进一个新天地&#xff0c;人都是一样的&#xff0c;面对自己不熟悉的领域总会…

i510300h和r54600h的区别 哪个好

i5 10300这个cpu&#xff0c;大约相当于台式机中的R5 2500u或者是i5 7500&#xff0c;性能比i5 7500还要弱一点。由于笔记本的低压&#xff0c;散热等关系&#xff0c;实际表现上是要弱于台式机的。频率&#xff08;基频2.5GHz、加速4.3GHz&#xff09;本身分别高了100、200MHz…

Android开发进阶:使用依赖注入函数库Roboguice

原文地址 &#xff1a;http://mobile.51cto.com/abased-426620.htm 本文原标题是如何成为一个偷懒又高效的Android开发人员&#xff0c;我敢肯定你对这个标题肯定心存疑惑&#xff0c;但事实就是如此&#xff0c;这个标题完全适合Android开发人员。据我所知&#xff0c; Androi…

MySQL结构以及数据管理(增删改查)

目录 1.数据库的简介 2.数据库分类 2.1关系型数据库 2.2 非关系型数据库 3.mysql的数据类型 3.1 常用的数据库类型 4.mysql的数据库结构 4.1 查看库信息 4.2 查看表信息 5.SQL 语句 5.1 SQL语言分类&#xff1a; 1.数据库的简介 数据库&#xff08;database&#…