• ViewFlow,一个滑动效果库


     

     
    第1种样式例子:用法: 

    Java代码
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTitle(R.string.circle_title);
    setContentView(R.layout.circle_layout);

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

    }
    布局: 
    Xml代码
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app
    ="http://schemas.android.com/apk/res/org.taptwo.android.widget.viewflow.example"
    android:orientation
    ="vertical"
    android:layout_width
    ="fill_parent"
    android:layout_height
    ="fill_parent"
    >
    <LinearLayout android:layout_height="wrap_content"
    android:layout_width
    ="fill_parent"
    android:gravity
    ="center_horizontal"
    android:orientation
    ="horizontal"
    android:id
    ="@+id/header_layout"
    >
    <org.taptwo.android.widget.CircleFlowIndicator
    android:padding="10dip"
    android:layout_height
    ="wrap_content"
    android:layout_width
    ="wrap_content"
    android:id
    ="@+id/viewflowindic"
    android:background
    ="#00000000"
    />
    </LinearLayout>
    <org.taptwo.android.widget.ViewFlow
    android:id="@+id/viewflow"
    android:layout_width
    ="fill_parent"
    android:layout_height
    ="fill_parent"
    app:sidebuffer
    ="3"
    />
    </LinearLayout>

    第2种样式例子: 
    Java代码
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTitle(R.string.title_title);
    setContentView(R.layout.title_layout);

    viewFlow = (ViewFlow) findViewById(R.id.viewflow);
    AndroidVersionAdapter adapter = new AndroidVersionAdapter(this);
    viewFlow.setAdapter(adapter);
    TitleFlowIndicator indicator = (TitleFlowIndicator) findViewById(R.id.viewflowindic);
    indicator.setTitleProvider(adapter);
    viewFlow.setFlowIndicator(indicator);

    }
    布局: 
    Java代码
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app
    ="http://schemas.android.com/apk/res/org.taptwo.android.widget.viewflow.example"
    android:orientation
    ="vertical"
    android:layout_width
    ="fill_parent"
    android:layout_height
    ="fill_parent"
    >
    <LinearLayout android:layout_width="fill_parent"
    android:gravity
    ="center_horizontal"
    android:id
    ="@+id/header_layout"
    android:orientation
    ="vertical"
    android:layout_height
    ="wrap_content"
    >
    <org.taptwo.android.widget.TitleFlowIndicator
    android:id="@+id/viewflowindic"
    android:layout_height
    ="wrap_content"
    android:layout_width
    ="fill_parent"
    app:footerLineHeight
    ="2"
    app:footerTriangleHeight
    ="10"
    app:textColor
    ="#FFFFFFFF"
    app:selectedColor
    ="#FFFFC445"
    app:footerColor
    ="#FFFFC445"
    app:titlePadding
    ="10"
    app:textSize
    ="13"
    android:layout_marginTop
    ="10dip"
    />

    </LinearLayout>
    <org.taptwo.android.widget.ViewFlow
    android:duplicateParentState="true"
    android:id
    ="@+id/viewflow"
    android:layout_width
    ="fill_parent"
    android:layout_height
    ="fill_parent"
    />
    </LinearLayout>
    自定义属性也一起贴上,方便参考:
    <?xml version="1.0" encoding="utf-8"?>
    <!-- Copyright (C) 2011 Tap2 AB <http://taptwo.se>

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
    -->

    <resources>
    <declare-styleable name="ViewFlow">
    <attr name="sidebuffer" format="integer" />
    </declare-styleable>
    <declare-styleable name="CircleFlowIndicator">
    <attr name="fillColor" format="color" />
    <attr name="strokeColor" format="color" />
    <attr name="radius" format="integer" />
    </declare-styleable>
    <declare-styleable name="TitleFlowIndicator">
    <attr name="titlePadding" format="integer" />
    <attr name="selectedColor" format="color" />
    <attr name="textColor" format="color" />
    <attr name="textSize" format="float" />
    <attr name="footerLineHeight" format="integer" />
    <attr name="footerColor" format="color" />
    <attr name="footerTriangleHeight" format="integer" />
    </declare-styleable>
    </resources>


    开源代码地址:https://github.com/pakerfeldt/android-viewflow
    测试代码地址:https://files.cnblogs.com/shanzei/viewflow-example.rar
  • 相关阅读:
    topcoder srm 495 div1
    topcoder srm 500 div1
    topcoder srm 485 div1
    topcoder srm 490 div1
    IDEWorkspaceChecks.plist文件是干什么用的?
    博客推荐
    如何使用U盘安装macOS high Sierra?
    小程序--模板消息调研
    小程序--剖析小程序上传文件
    小程序--小程序开发过程中遇到的问题以及解决方案
  • 原文地址:https://www.cnblogs.com/shanzei/p/2415652.html
Copyright © 2020-2023  润新知