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()

 

Android——ViewFilper轮播图

上一篇:前向否定界定符 python正则表达式不匹配某个字符串 以及无捕获组和命名组(转)


下一篇:10大影响力人物教你如何做好用户体验?