首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >圆形页面指示器-如何更改填充颜色更改

问圆形页面指示器-如何更改填充颜色更改
EN

Stack Overflow用户
提问于 2014-04-23 16:00:04
回答 4查看 22.4K关注 0票数 16

我在我的安卓应用程序中使用了ViewPageIndicator,,特别是CirclePageIndictor。要求是fillColor将直接移动到指示器中的下一个圆圈,而不是像图片中这样的情况(圆圈移动缓慢,在翻页时停留在中间)

我该怎么做呢?

​

EN

回答 4

Stack Overflow用户

发布于 2014-06-19 18:14:50

您可以在您的xml上尝试以下内容:

代码语言:javascript
复制
<com.viewpagerindicator.CirclePageIndicator
        android:id="@+id/indicator"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:padding="10dip"
        app:radius="12dp"
        app:fillColor="@color/header_bg_color"
        app:pageColor="#ffffff"
        app:strokeColor="@color/header_bg_color"/>

别忘了在你的布局中添加xmlns:app="http://schemas.android.com/apk/res-auto“。E.g

代码语言:javascript
复制
 <LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        />

    <com.viewpagerindicator.CirclePageIndicator
            android:id="@+id/indicator"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="10dip"
            app:radius="12dp"
            app:fillColor="@color/header_bg_color"
            app:pageColor="#ffffff"
            app:strokeColor="@color/header_bg_color"/>

</LinearLayout>
票数 36
EN

Stack Overflow用户

发布于 2014-04-23 16:05:36

将snap属性设置为true。

代码语言:javascript
复制
vpi:snap="true"

或

代码语言:javascript
复制
vpi.setSnap(true);
票数 5
EN

Stack Overflow用户

发布于 2014-04-23 17:50:05

代码语言:javascript
复制
final CirclePageIndicator circleIndicator = (CirclePageIndicator) findViewById(R.id.indicator);
    circleIndicator.setViewPager(_pager);
    final float density = getResources().getDisplayMetrics().density;
    circleIndicator.setFillColor(0xFFFFFFFF);
    circleIndicator.setStrokeColor(0xFFFFFFFF);
    circleIndicator.setStrokeWidth(1);
    circleIndicator.setRadius(6 * density);
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23238298

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档