更改com.tech.freak.wizardpager.ui.StepPagerStrip的颜色

时间:2017-10-20 02:21:56

标签: android layout

我正在为我的android项目使用com.tech.freak.wizardpager库。 我只是想知道当我在向导页面时如何更改步骤颜色。

我在库代码中看到了这一点,但是在更改资源时没有任何反应:

public StepPagerStrip(Context context, AttributeSet attrs, int defStyle) {

        super(context, attrs, defStyle);

        final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
        mGravity = a.getInteger(0, mGravity);
        a.recycle();

        final Resources res = getResources();
        mTabWidth = res.getDimensionPixelSize(R.dimen.step_pager_tab_width);
        mTabHeight = res.getDimensionPixelSize(R.dimen.step_pager_tab_height);
        mTabSpacing = res.getDimensionPixelSize(R.dimen.step_pager_tab_spacing);

        mPrevTabPaint = new Paint();
        mPrevTabPaint.setColor(res.getColor(R.color.step_pager_previous_tab_color));

        mSelectedTabPaint = new Paint();
        mSelectedTabPaint.setColor(res.getColor(R.color.step_pager_selected_tab_color));

        mSelectedLastTabPaint = new Paint();
        mSelectedLastTabPaint.setColor(res.getColor(R.color.step_pager_selected_last_tab_color));

        mNextTabPaint = new Paint();
        mNextTabPaint.setColor(res.getColor(R.color.step_pager_next_tab_color));
    }

我修改颜色xml

<resources>
    <color name="step_pager_previous_tab_color">#6303a9f4</color>
    <color name="step_pager_selected_tab_color">#ffffff</color>
    <color name="step_pager_selected_last_tab_color">#ffffff</color>
    <color name="step_pager_next_tab_color">#a8212121</color>

    <color name="review_green">@android:color/white</color>

    <color name="text_light">#66000000</color>
    <color name="white">#ffffff</color>
</resources>

但只需更改评论页面颜色(最后一个) 有人用这个库吗?

尝试覆盖颜色但出现此错误:

Error:Execution failed for task ':app:mergeDebugResources'.
> [color/step_pager_selected_last_tab_color] C:\Users\NEO\AndroidStudioProjects\elbache\app\src\main\res\values\styles.xml  [color/step_pager_selected_last_tab_color] C:\Users\NEO\AndroidStudioProjects\elbache\app\src\main\res\values\colors.xml: Error: Duplicate resources
[color/step_pager_next_tab_color] C:\Users\NEO\AndroidStudioProjects\elbache\app\src\main\res\values\styles.xml [color/step_pager_next_tab_color] C:\Users\NEO\AndroidStudioProjects\elbache\app\src\main\res\values\colors.xml: Error: Duplicate resources
[color/text_light] C:\Users\NEO\AndroidStudioProjects\elbache\app\src\main\res\values\styles.xml    [color/text_light] C:\Users\NEO\AndroidStudioProjects\elbache\app\src\main\res\values\colors.xml: Error: Duplicate resources
[color/step_pager_selected_tab_color] C:\Users\NEO\AndroidStudioProjects\elbache\app\src\main\res\values\styles.xml [color/step_pager_selected_tab_color] C:\Users\NEO\AndroidStudioProjects\elbache\app\src\main\res\values\colors.xml: Error: Duplicate resources
[color/step_pager_previous_tab_color] C:\Users\NEO\AndroidStudioProjects\elbache\app\src\main\res\values\styles.xml [color/step_pager_previous_tab_color] C:\Users\NEO\AndroidStudioProjects\elbache\app\src\main\res\values\colors.xml: Error: Duplicate resources

1 个答案:

答案 0 :(得分:0)

尝试在您自己的color.xml中覆盖颜色

<resources 
     xmlns:app="http://schemas.android.com/tools">

     <color name="step_pager_previous_tab_color" app:override="true">#6303a9f4</color>
     <color name="step_pager_selected_tab_color" app:override="true">#ffffff</color>
     <color name="step_pager_selected_last_tab_color" app:override="true">#ffffff</color>
     <color name="step_pager_next_tab_color" app:override="true">#a8212121</color>

     <color name="review_green" app:override="true">#ffffff</color>

     <color name="text_light" app:override="true">#66000000</color>
     <color name="white">#ffffff</color>
</resources>