标签:
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); } }
主窗口布局:
<?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>
注:app:sidebuffer属性是ViewFlow组件自定义的,故使用时,需增加命名空间:xmlns:app="http://schemas.android.com/apk/res/your.application.package"
图片适配器:
标签:
原文地址:http://www.cnblogs.com/qq1274540609/p/4682351.html