• viewpage 小圆点


    <LinearLayout  
            android:id="@+id/viewGroup"  
            android:layout_width="fill_parent"  
            android:layout_height="wrap_content"  
            android:layout_alignParentBottom="true"  
            android:layout_marginBottom="30dp"  
            android:gravity="center_horizontal"  
            android:orientation="horizontal" >  
        </LinearLayout> 

    // group是R.layou.main中的负责包裹小圆点的LinearLayout.  
            group = (ViewGroup)main.findViewById(R.id.viewGroup);  
     
            viewPager = (ViewPager)main.findViewById(R.id.guidePages);  
     
            for (int i = 0; i < pageViews.size(); i++) {  
                imageView = new ImageView(GuideViewDemoActivity.this);  
                imageView.setLayoutParams(new LayoutParams(20,20));  
                imageView.setPadding(20, 0, 20, 0);  
                imageViews[i] = imageView;  
                if (i == 0) {  
                    //默认选中第一张图片
                    imageViews[i].setBackgroundResource(R.drawable.page_indicator_focused);  
                } else {  
                    imageViews[i].setBackgroundResource(R.drawable.page_indicator);  
                }  
                group.addView(imageViews[i]);  
            }

      @Override  
            public void onPageSelected(int arg0) {  
                for (int i = 0; i < imageViews.length; i++) {  
                    imageViews[arg0]  
                            .setBackgroundResource(R.drawable.page_indicator_focused);  
                    if (arg0 != i) {  
                        imageViews[i]  
                                .setBackgroundResource(R.drawable.page_indicator);  
                    }  
                }
     
            } 

    <LinearLayout android:layout_width="wrap_content"
                android:layout_height="35dip"
                android:layout_gravity="bottom|center_horizontal"
                android:gravity="center" >
                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center">
                    <View
                        android:id="@+id/dot01"
                        style="@style/dot_style"
                        android:background="@drawable/dot_focused"/>
                    <View
                         android:id="@+id/dot02"
                        style="@style/dot_style"
                        android:layout_marginLeft="10dip"/>
                    <View
                         android:id="@+id/dot03"
                        style="@style/dot_style"
                        android:layout_marginLeft="10dip"/>
                    <View
                         android:id="@+id/dot04"
                         style="@style/dot_style"
                         android:layout_marginLeft="10dip"/>
            </LinearLayout>
                
            </LinearLayout>

    dot_style.xml

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <style name="dot_style">
            <item name="android:layout_width">5dip</item>
            <item name="android:layout_height">5dip</item>
            <item name="android:background">@drawable/dot_normal</item>
            <item name="android:layout_marginLeft">1.5dip</item>
            <item name="android:layout_marginRight">1.5dip</item>
        </style>
    </resources>

    <?xml version="1.0" encoding="utf-8"?>  dot_focused
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="oval" >
        <solid android:color="#FFFFFF" />
        <corners android:radius="5dip" />
    </shape>

    <?xml version="1.0" encoding="utf-8"?>   dot_normal
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="oval" >
        <solid android:color="#aaFFFFFF" />
        <corners android:radius="5dip" />
    </shape>

     private void initDots() {
            listDots = new ArrayList<View>();
            listDots.add(findViewById(R.id.dot01));
            listDots.add(findViewById(R.id.dot02));
            listDots.add(findViewById(R.id.dot03));
            listDots.add(findViewById(R.id.dot04));
        }

    ((View)listDots.get(position)).setBackgroundResource(R.drawable.dot_focused);
    ((View)listDots.get(oldPosition)).setBackgroundResource(R.drawable.dot_normal);

  • 相关阅读:
    Django修改数据库时出错 django.db.utils.OperationalError: (1091, "Can't DROP 'content'; check that column/key exists")
    ini配置文件必知
    常用的两个批处理
    windows Path变量优先级
    curl开源库编译
    VS属性页的目录类型
    连通域去噪
    C++调用V8与JS交互
    VS2010,Qt插件安装使用
    utf8转gbk,libcurl中文乱码处理
  • 原文地址:https://www.cnblogs.com/jiezzy/p/2652705.html
Copyright © 2020-2023  润新知