Android——ViewFilper轮播图

时间:2021-09-04
本文章向大家介绍Android——ViewFilper轮播图,主要包括Android——ViewFilper轮播图使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

介绍

  ViewFilper是Android中轮播图组件。这是一个ViewGroup和RaidoGroup一样包裹图片来作为内容,通过设置inAnimation和outAnimation达到图片的切换效果。

方法

  public void startFlipping()

    参数:无

    返回值;无  

    返回值意义:无

    作用:开启轮播,使用inAnimation和outAnimation绑定的效果轮播图片

属性

  inAnimation:进入的动画效果

  outAnimation:离开的动画效果

使用

  1. 在ViewFilper中用<inculde layout="" > 绑定图片

  2. 设置inAnimation和outAnimation,进入和离开的动画效果

  3. startFlipping() 开启轮播效果

    <ViewFlipper
        android:layout_width="match_parent"
        android:layout_height="130dp"
        android:inAnimation="@anim/in02"
        android:outAnimation="@anim/out02"
        android:id="@+id/vf">

        <include layout="@layout/vflipper_show1"/>
        <include layout="@layout/vflipper_show2"/>
        <include layout="@layout/vflipper_show3"/>
        <include layout="@layout/vflipper_show4"/>
        <include layout="@layout/vflipper_show5"/>
        <include layout="@layout/vflipper_show6"/>
        <include layout="@layout/vflipper_show7"/>

    </ViewFlipper>

// inAnimation
<set
    android:duration="300"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:fromXDelta="100%p"
        android:fromYDelta="0"
        android:toXDelta="0"
        android:toYDelta="0"/>
</set>


// outAnimation 
<set
    android:duration="300"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:fromXDelta="0"
        android:fromYDelta="0"
        android:toXDelta="-100%p"
        android:toYDelta="0"/>
</set>

viewFilper.startFilpping()

原文地址:https://www.cnblogs.com/remix777/p/15227671.html