Viewpager Relex 圆形指示器 颜色

13

viewpager指示器的默认颜色为白色。
在github上的relex viewpager指示器中,
它没有提供如何更改指示器颜色的方法。
这可行吗?

  <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <me.relex.circleindicator.CircleIndicator
                android:id="@+id/pagerIndicator"
                app:ci_width="10dp"
                app:ci_height="10dp"
                android:layout_width="match_parent"
                android:layout_height="36dp"
                android:layout_gravity="bottom"
                android:layout_marginBottom="8dp" />
        </LinearLayout>

请在库线程上询问此问题。 - Vivek Mishra
2个回答

24
    <me.relex.circleindicator.CircleIndicator
        android:id="@+id/pagerIndicator"
        app:ci_width="10dp"
        app:ci_height="10dp"
        app:ci_drawable="@drawable/circleindicator_round"
        android:layout_width="match_parent"
        android:layout_height="36dp"
        android:layout_gravity="bottom"
        android:layout_marginBottom="8dp" />

我不在意你使用什么填充或边距

但请创建一个可绘制的XML文件并添加以下代码

<?xml version="1.0" encoding="utf-8"?>
  <shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="@color/colorAccent"/>
    <corners android:radius="10dp"/>
  </shape>

叫它任何你想要的名字

`app:ci_drawable="@drawable/circleindicator_round"`

对我有用


完美。谢谢 :) - dennisrufigill

5

从 Github 页面:在属性下面

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <me.relex.circleindicator.CircleIndicator
            android:id="@+id/pagerIndicator"
            app:ci_width="10dp"
            app:ci_height="10dp"
            app:ci_drawable="your drawable defining the color"
            android:layout_width="match_parent"
            android:layout_height="36dp"
            android:layout_gravity="bottom"
            android:layout_marginBottom="8dp" />
</LinearLayout>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接