Android UI—引导页ViewPager使用
由于工作需要,准备转型Android开发。对于公司来说,可以集中力量开发Android产品,加快开发进度;对于个人来说,掌握另一门编程语言,也是提升自我的一个机会,正所谓技多不压身^^。
前言
今天学习了ViewPager控件的基本使用方法,实现了引导页的滑动、导航点的添加、进入主页面按钮、首次启动显示引导页,再次启动直接进入主页面等功能。总结如下:
一.引导页XML + Activity
1.引导页布局文件:导航点布局文件:one.xml … 、guide.xml
在layout布局文件中新建one.xml导航点,tow.xml、three.xml类似one.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/guide_1"/>
</LinearLayout>
新建guide.xml,并定义三个ImageView:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#00000000"
>
</android.support.v4.view.ViewPager>
<LinearLayout
android:id="@+id/ll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/iv1"
android:src="@drawable/login_point_selected"/>
<ImageView
android:layout_width="wrap_content&#