This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 36031 - Button border not drawn on Android without a BorderRadius
Summary: Button border not drawn on Android without a BorderRadius
Status: VERIFIED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android (show other bugs)
Version: 1.5.2
Hardware: PC Mac OS
: Highest normal
Target Milestone: ---
Assignee: Rui Marinho
URL:
: 51102 58258 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-11-18 22:52 UTC by Adam Patridge
Modified: 2017-07-19 22:12 UTC (History)
20 users (show)

See Also:
Tags: ac, button, android, border
Is this bug a regression?: ---
Last known good build:


Attachments
Drop-in PCL Xamarin.Forms app C# file for a new project. (1.75 KB, application/octet-stream)
2015-11-18 22:52 UTC, Adam Patridge
Details

Description Adam Patridge 2015-11-18 22:52:15 UTC
Created attachment 13880 [details]
Drop-in PCL Xamarin.Forms app C# file for a new project.

[Also affects Xamarin.Forms v2.0.0.6482.]

If a Button has a BorderColor and BorderWidth set, but a 0 BorderRadius, when rendered on Android, the border will not be shown.

Reproduction code (as included in the full PCL app attached):

> new Button {
> 	Text = "BorderWidth = 1, BorderRadius = 0,",
> 	HorizontalOptions = LayoutOptions.Center,
> 	BackgroundColor = Color.Black,
> 	BorderColor = Color.Red,
> 	BorderWidth = 1,
> 	BorderRadius = 0,
> },

A screenshot of this code run on API 22 is included in a related Stack Overflow answer.

http://stackoverflow.com/a/33792652/48700
Comment 1 Alma Jensen 2015-12-02 05:19:39 UTC
I tested this on a Samsung Galaxy S5 and BorderWidth, Radius, and Color all do not seem to work in Xamarin Forms 2+.
Comment 2 René 2016-03-12 14:02:52 UTC
Still an issue in 2.0.1.6505 but even setting a border radius doesn't seem to fix it anymore.
Comment 3 Adam Patridge 2016-03-12 18:43:14 UTC
René, depending on what size border width you are using, that may be making it worse for you. It is possible that there is a link between border visibility and border width combined with border radius. One comment on this SO answer mentions that thick borders require more radius to show up: http://stackoverflow.com/a/33792652/48700. It's not a pretty solution, but it might work for you.
Comment 4 Andrei.N 2016-10-19 09:01:18 UTC
It depends if you are using FormsAppComat or not.

https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android/AppCompat/ButtonRenderer.cs
https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android/Renderers/ButtonRenderer.cs

If you look to the code of the AppCompat Button renderer code, the 'BorderColor' property is not used at all, which means border color is not implemented.
Comment 5 tim.ahrentlov 2016-11-24 13:22:27 UTC
So. Will BorderColor ever be implemented for FormsAppCompat ?
Comment 6 Samantha Houts 2016-12-28 19:58:29 UTC
*** Bug 51102 has been marked as a duplicate of this bug. ***
Comment 7 Seifer 2017-02-10 17:32:32 UTC
Any news on this?
Comment 8 Dimitar Dobrev 2017-04-11 09:27:03 UTC
This bug is more than a year and a half old, when is it going to be fixed? The workaround at https://forums.xamarin.com/discussion/comment/165832/#Comment_165832 no longer works.
Comment 9 Jeroen 2017-05-19 08:17:08 UTC
This workaround still seems to work:

using Xamarin.Forms.Platform.Android;
using Xamarin.Forms;
 
[assembly: ExportRenderer(typeof(Button), typeof(Droid.Renderers.BorderButtonRenderer))]
namespace Droid.Renderers
{
   /// <summary>
   /// Custom renderer for buttons with a custom border
   /// </summary>
   public class BorderButtonRenderer : ButtonRenderer
   {
      protected override void OnDraw(Android.Graphics.Canvas canvas)
      {
         base.OnDraw(canvas);
      }

      protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
      {
         base.OnElementChanged(e);
      }
   }
}
Comment 11 Rui Marinho 2017-06-01 10:29:35 UTC
Should be fixed on 2.3.6-pre1
Comment 12 Rui Marinho 2017-06-26 15:55:30 UTC
Moved the fixed to 2.3.5-pre6
Comment 17 Paul DiPietro 2017-07-13 19:26:52 UTC
I have tested the originally provided code against the 2.3.5-pre6 build (making changes to correctly display a white font color) and the borders are showing as expected. I suspect you may have to properly clean/rebuild and delete bin/obj/package folders as necessary. I will attach a screenshot of my emulator.
Comment 19 Saurabh Paunikar 2017-07-17 06:34:34 UTC
Verified on Xamarin.Form version 2.3.5.256-pre6.

ScreenCast Link : https://www.screencast.com/t/X0SVYIgKW
Comment 20 Jimmy 2017-07-19 22:12:46 UTC
*** Bug 58258 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.