我使用CirclePagerIndicator https://github.com/JakeWharton/ViewPagerIndicator但我需要使用图像资源定制整个绘制对象。一个用于选定页面,另一个用于未选择状态。现在这个库只能接受颜色。有没有办法或替代做到这一点?Android - CirclePageIndicator自定义可绘制
这就是我想要做的事:
final float density = getResources().getDisplayMetrics().density;
circlePageIndicator.setStrokeWidth(2);
circlePageIndicator.setStrokeColor(getActivity().getResources().getColor(R.color.white)); //<== need resource image here not color
circlePageIndicator.setRadius(6 * density);
感谢。
编辑
因为我还没有找到任何解决办法左右,我决定创建自己的库来做到这一点,inspirated到杰克沃顿CirclePageIndicator。我发布一个链接,应该帮助那些谁需要它:
https://github.com/augustopicciani/DrawablePageIndicator
谢谢,我知道,但我需要在fillColor和pageColor中设置@ drawable/my_icon。不能使用颜色,因为图标有点复杂,并且它在状态选择和非选择之间应该有不同的笔划。 –
@AugustoPicciani //这可能是痛苦。您可能需要定义您自己的可绘制属性。 – Youngjae
好的,有一种方法可以通过程序从代码中设置笔画,这种代码会在选择状态和未选择状态时进行更改。 –