使用ViewPager实现android软件使用向导功能实现步骤

前端技术 2023/09/05 Android



首先需要一个布局文件,是FlameLayout组成的,里面包含了一个ViewPager和一个RelativeLayout,RelativeLayout里面是一个LinearLayout,LinearLayout里面是准备放ImageView,动态添加。

布局文件如下:

复制代码 代码如下:

<?xml version=\"1.0\" encoding=\"utf-8\"?>
<FrameLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"
    android:layout_width=\"match_parent\"
    android:layout_height=\"match_parent\"
    android:orientation=\"vertical\" >

    <android.support.v4.view.ViewPager
        android:id=\"@+id/guidePages\"
        android:layout_width=\"match_parent\"
        android:layout_height=\"wrap_content\"
        android:layout_gravity=\"center\" />

    <RelativeLayout
        android:layout_width=\"match_parent\"
        android:layout_height=\"wrap_content\"
        android:layout_gravity=\"bottom\">
        <LinearLayout
            android:id=\"@+id/viewGroup\"
            android:layout_alignParentBottom=\"true\"
            android:layout_width=\"match_parent\"
            android:layout_height=\"wrap_content\"
            android:orientation=\"horizontal\"
            android:gravity=\"center\"
            android:layout_marginBottom=\"30dip\">

        </LinearLayout>
    </RelativeLayout>
</FrameLayout>

另外我们需要4个布局文件,就是向导要显示的图片,每个布局文件是一页,每个布局文件里面都是一个ImageView。如下所示:

布局文件一:

复制代码 代码如下:

<?xml version=\"1.0\" encoding=\"utf-8\"?>
<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"
    android:layout_width=\"match_parent\"
    android:layout_height=\"match_parent\"
    android:orientation=\"vertical\" >

    <ImageView
        android:layout_width=\"match_parent\"
        android:layout_height=\"match_parent\"
        android:src=\"@drawable/feature_guide_0\"/>\"

</LinearLayout>

本文地址:https://www.stayed.cn/item/14701

转载请注明出处。

本站部分内容来源于网络,如侵犯到您的权益,请 联系我

我的博客

人生若只如初见,何事秋风悲画扇。