RobertApikyan / SegmentedControl

Android SegmentedControl + multi row support
Apache License 2.0
162 stars 30 forks source link

Can not change colors programatically #5

Closed j-ns closed 6 years ago

j-ns commented 6 years ago

Hi Robert, this is the SegmentedControl I was looking for. Great work.

Unfortuanetly I'm not able to change colors programmatically. When I change e.g. the unselectedBackgroundColor, I get a purple background no matter what color I choose.

segmentedControl.setUnSelectedBackgroundColor(R.color.segmented_control_disabled);
segmentedControl.notifyConfigIsChanged();
RobertApikyan commented 6 years ago

Hi, thanks for positive review.

setUnSelectedBackgroundColor() method's argument must be a color value. Do not pass the resource value directly.

Here is the working example ..

SegmentedControl segmentedControl = findViewById(R.id.segmented_control);

int colorValue = ContextCompat.getColor(this, R.color.segmented_control_disabled) segmentedControl.setUnSelectedBackgroundColor(colorValue); _// here pass the color value, instead of R.color.segmented_controldisabled

segmentedControl.notifyConfigIsChanged();