设为首页 加入收藏

TOP

ViewPager+handler实现轮播(四)
2017-10-12 11:29:10 】 浏览:5963
Tags:ViewPager handler 实现
od stub
String message = null; switch (failReason.getType()) { case IO_ERROR: message = "Input/Output error"; break; case DECODING_ERROR: message = "Image can't be decoded"; break; case NETWORK_DENIED: message = "Downloads are denied"; break; case OUT_OF_MEMORY: message = "Out Of Memory error"; break; case UNKNOWN: message = "Unknown error"; break; } Log.i("ImagePagerAdapter", message); spinBar.setVisibility(View.GONE); } //加载完成 @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { // TODO Auto-generated method stub spinBar.setVisibility(View.GONE); } } /** * viewpager的滑动监听 * * @author Kevin * */ class GuidePageListener implements OnPageChangeListener { // 滑动事件 @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { // System.out.println("当前位置:" + position + ";百分比:" + positionOffset // + ";移动距离:" + positionOffsetPixels); int len = (int) (mPointWidth * positionOffset) + position * mPointWidth; RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) viewRedPoint .getLayoutParams();// 获取当前红点的布局参数 params.leftMargin = len;// 设置左边距 viewRedPoint.setLayoutParams(params);// 重新给小红点设置布局参数 } // 某个页面被选中 @Override public void onPageSelected(int position) { } // 滑动状态发生变化 @Override public void onPageScrollStateChanged(int state) { } } }
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:id="@+id/rl_root"
        android:layout_height="200dp" >

        <android.support.v4.view.ViewPager
            android:id="@+id/viewpager1"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="20dp" >

            <LinearLayout
                android:id="@+id/ll_point_group"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="horizontal" >
            </LinearLayout>

            <View
                android:id="@+id/view_red_point"
                android:layout_width="8dp"
                android:layout_height="8dp"
                android:background="@drawable/point_selecte" />
        </RelativeLayout>
    </RelativeLayout>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/app_name" />

</LinearLayout>
<?xml version="1.0" encoding="
首页 上一页 1 2 3 4 5 下一页 尾页 4/5/5
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇仿微信底部TAG完美渐变 下一篇圆形ImageView(可设置边缘厚度和..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目