码迷,mamicode.com
首页 > 其他好文 > 详细

ViewFlow左右滑动效果

时间:2015-07-28 12:29:10      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:

viewflow是android开源的控件,发布在github网站上。下载地址是:https://github.com/pakerfeldt/android-viewflow


 

1、CircleFlowIndicator

运行如下:

技术分享 技术分享

代码如下:

主窗口:

技术分享
public class CircleViewFlowExample extends Activity {

    private ViewFlow viewFlow;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.circle_layout);

        viewFlow = (ViewFlow) findViewById(R.id.viewflow);
        viewFlow.setAdapter(new ImageAdapter(this), 5);
        CircleFlowIndicator indic = (CircleFlowIndicator) findViewById(R.id.viewflowindic);
        viewFlow.setFlowIndicator(indic);
    }

    /*
     * If your min SDK version is < 8 you need to trigger the
     * onConfigurationChanged in ViewFlow manually, like this
     */
    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        viewFlow.onConfigurationChanged(newConfig);
    }
}
CircleViewFlowExample.java

主窗口布局

技术分享
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res/com.zxm.a"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <org.taptwo.android.widget.CircleFlowIndicator
        android:padding="10dip"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:id="@+id/viewflowindic"
        android:layout_gravity="center_horizontal"
        app:inactiveType="fill"
        app:fadeOut="1000" />
    <org.taptwo.android.widget.ViewFlow
        android:id="@+id/viewflow"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:sidebuffer="3" />

</FrameLayout>
circle_layout.xml

注:app:sidebuffer属性是ViewFlow组件自定义的,故使用时,需增加命名空间:xmlns:app="http://schemas.android.com/apk/res/your.application.package"

图片适配器:

 

ViewFlow左右滑动效果

标签:

原文地址:http://www.cnblogs.com/qq1274540609/p/4682351.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!