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

layout_width and layout height is't not work,always the same size #96

Open
juziml opened this issue Aug 2, 2017 · 10 comments
Open

layout_width and layout height is't not work,always the same size #96

juziml opened this issue Aug 2, 2017 · 10 comments

Comments

@juziml
Copy link

juziml commented Aug 2, 2017

when I use layout_width=200dp or layout height=50dp in xml file
I realize it's always the same size
i changed code in onMeasure method,but is't not work
I need you help
thanks!

@huang-xinjie
Copy link

huang-xinjie commented Aug 3, 2017

I have this problem, too.
It took me a day, but it didn't work out..

And I try to use
app:kswThumbWidth="18dp" app:kswThumbHeight="18dp",
but nothing changed.

@kyleduo
Copy link
Owner

kyleduo commented Aug 4, 2017

Since SwitchButton use kswBackMeasureRatio to determine how width the background to be drawn with, layout_width and layout_height do change the view bounds but SwitchButton will also draw the background and thumb as they were assigned with kswThumbWidth, kswThumbHeight and kswBackMeasureRatio.
If you want to change the real drawn size, use these 3 attributes instead. I'll think about improving the measuring and drawing calculation.
Thanks for your feedback.

@huang-xinjie
Copy link

huang-xinjie commented Aug 4, 2017

Yes, I've already used them
app:kswAnimationDuration="300" app:kswBackDrawable="@drawable/ios_back_drawable" app:kswThumbDrawable="@drawable/ios_thumb_selector" app:kswBackMeasureRatio="1.7" app:kswThumbMarginBottom="-8dp" app:kswThumbMarginLeft="-6dp" app:kswThumbMarginRight="-8dp" app:kswThumbMarginTop="-5dp" app:kswThumbWidth="18dp" app:kswThumbHeight="18dp"

but it's always the same size.
It's too big, in my layout.
I tried all kinds of ways I could think of it, but ~~

thanks!

===========================================

And I've tried to use setThumbSize in code, but app has stopped.

@kyleduo
Copy link
Owner

kyleduo commented Aug 4, 2017

Maybe you put your drawable in wrong directory.

@huang-xinjie
Copy link

OMG!!!
You're right!!
It works!! It works!!
thank you so much!!

@kyleduo
Copy link
Owner

kyleduo commented Aug 4, 2017

You are welcome~
By now, SwitchButton use Drawable's minimal size, usually it's instinct size, to determine the thumb size. May be I should increase the priority of kswThumbWidth and kswThumbHeight to override the Drawable's size with them, I'll think about it as well.

@huang-xinjie
Copy link

Support you, thank you very much for releasing this cool project. It's awesome!

@maxglu
Copy link

maxglu commented Oct 12, 2017

Hi! @kyleduo thanks for excelent switch, its perfect.
I have the same issue. I read messages above and found temporary solution with using images with different size.
But I think

increase the priority of kswThumbWidth and kswThumbHeight

it will be a perfect idea.

@kyleduo
Copy link
Owner

kyleduo commented Nov 2, 2017

New version has released and I suggest having a try.

@maxglu
Copy link

maxglu commented Nov 10, 2017

Thank you!

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

No branches or pull requests

4 participants