[Android] Buttons can be round; remove Padding & Shadow by default#1935
[Android] Buttons can be round; remove Padding & Shadow by default#1935
Conversation
fixes #1909
if I want to hide the shadow, |
|
@bill2004158 Not to worry, we'll be revising this PR to make it possible to hide the shadow. That's why it's marked as do-not-merge right now. Thanks! |
|
I understand some poeple had problems with previous changes but now reverting or redoing those changes breaks others. I was quite happy with the previous version indeed. would you mind sharing all styles you have removed that we can set in the shared library? because when I look at your commits I am bit lost. some padding are set dynamically looks like. |
|
Hi @EmilAlipiev! If you were happy with the way it looked as of #1570, then you want to do: using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.AndroidSpecific;
…
_button.On<Android>().SetUseDefaultPadding(true).SetUseDefaultShadow(true);I would have liked to have those settings enabled by default, but that was, unfortunately, a behavioral change that would have broken old apps. Let me know if you have any further questions. Thanks! |
|
That's one way to do it. You can apply this platform specific property to a standard Button, too. See https://docs.microsoft.com/en-us/xamarin/xamarin-forms/platform/platform-specifics/consuming/android for some examples of how to use platform specifics. Thanks! |
Description of Change
Removing the Padding and Shadow that were added in #1570 to make the X.F. Buttons mimic the style of a default Android
Button. These can be added back to Buttons using new Platform Specifics.Also adjusting the padding mismatch that made circle Buttons appear to be slightly rectangular.
Before #1570:

After #1570:

After this change (note, changed the test case for an additional parameter):

Bugs Fixed
API Changes
Added:
bool Button.On<Android>().UseDefaultPadding()void Button.On<Android>().SetUseDefaultPadding(true/false)bool Button.On<Android>().UseDefaultShadow()void Button.On<Android>().SetUseDefaultShadow(true/false)Behavioral Changes
CornerRadius,BackgroundColor,BorderColor, orBorderWidthproperties will replace the Background drawable of an Android Button. If you need to use a custom drawable, please incorporate all of these properties into your custom drawable instead of attempting to use the Xamarin.Forms properties to adjust some or all of those values.PR Checklist