react-native-radio-buttons icon indicating copy to clipboard operation
react-native-radio-buttons copied to clipboard

Weird styling issue in SegmentedControl on Android

Open varungupta85 opened this issue 9 years ago • 4 comments

I am observing a weird styling issue while using SegmentedControl on Android. In the below screenshot, observe that there is a very small part that is white.

screen shot 2016-10-15 at 8 42 21 am

When I inspect it in the Inspector, it looks like below. The small white part is not part of the view.

screen shot 2016-10-15 at 10 17 03 am

Below is the code to render the SegmentedControl

<SegmentedControls options={this.props.values}
    selectedIndex={this.props.selectedIndex}
    onSelection={this.props.onChange}
    enabled={this.props.enabled ? true : false}
    containerStyle={{flex: 1, height: 32}}
    tint= {'dimgrey'}
    selectedTint= {'white'}
    backTint= {'white'}
  />

If flex: 1 is removed and a fixed width is provided, then the issue goes away. Any ideas on how to fix the problem.

cc @GantMan

varungupta85 avatar Oct 15 '16 04:10 varungupta85

DISCLAIMER: I suck at design.
Not sure we can do a fixed width there though. Isn't the behavior of the segment to be a variable width to match the screen size? Perhaps there's a nudge or negative padding we can add on the right side to get this to be flush. I'm open to ideas.

GantMan avatar Oct 15 '16 14:10 GantMan

I have never used negative padding or margins in css before but I guess you mean to just give a negative number instead of a positive number for the margin/padding value. I will give it a try and post the results.

varungupta85 avatar Oct 17 '16 05:10 varungupta85

negative numbers in padding/margins is something I do that makes REAL designers curse my name :) But it gets stable results, for sure.

GantMan avatar Oct 17 '16 14:10 GantMan

FYI I'm running into this same issue on iOS, so I don't think it's platform-dependent. I worked around it by adding marginRight: -1 to my optionContainerStyle, but it's weird that that's necessary.

corbt avatar Apr 08 '17 16:04 corbt