Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch View looks cut on my android(4.4.2). #21

Open
zyan-dev opened this issue Mar 3, 2017 · 2 comments
Open

Switch View looks cut on my android(4.4.2). #21

zyan-dev opened this issue Mar 3, 2017 · 2 comments

Comments

@zyan-dev
Copy link

zyan-dev commented Mar 3, 2017

screen shot 2017-03-03 at 10 17 11 am

@allpwrfulroot
Copy link

Dive into the component's index.js in node_modules and change the padding set in the constructor:

this.padding = 6 // was originally 2

Did the trick for me, although I've only checked the results on one Android device and with my own custom switch:

<Switch
    buttonRadius={10}
    switchHeight={12}
    switchWidth={32}
   ...
  />

@Jazz747
Copy link

Jazz747 commented Apr 20, 2017

Yes, padding increase works only for this or similar setup.

For permanent fix (or I hope it is, tested on various dimensions), in node_modules/index.js change:

parent View that starts on line 201, in his style add:

 marginTop: this.props.buttonRadius/2,
 marginLeft: this.props.buttonRadius/2,

modify TouchableHighlight's width like so:

width: this.props.switchWidth+doublePadding+this.props.buttonRadius,

(add '+this.props.buttonRadius' to it)

and modify Animated.View's top and lett absolute values like so:

top: halfPadding + this.props.switchHeight/2 - this.props.buttonRadius/2,
left: this.props.switchHeight/2 > this.props.buttonRadius ? halfPadding : halfPadding + this.props.switchHeight/2 - this.props.buttonRadius/2,

(basically just add '/2' to the end.)

this makes the switch travel area and the button circle centered in container View instead of starting in the top left corner and should solve this issue. Since I'm new to the github mechanics of forking and pull requests and mostly lazy (:D), could someone who is working actively on this project test it out and introduce the changes? cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants