- Home
- Forum
- Xamarin.Forms
- How to remove the underline in SfAutoComplete?
How to remove the underline in SfAutoComplete?
5 Replies
MK
Muneesh Kumar G
Syncfusion Team
August 21, 2019 09:56 AM UTC
Hi Bharath,
Greetings from Syncfusion.
We have analyzed your requirement and we have achieved this by using custom renderer with Rounded Corner and without underline in SfAutoComplete. Please have the code snippet and sample from the below link,
Code Snippet:
|
Android:
if (Control != null)
{
GradientDrawable gd = new GradientDrawable();
gd.SetColor(Android.Graphics.Color.White);
gd.SetCornerRadius(12);
gd.SetStroke(2, Android.Graphics.Color.LightGray);
this.Control.SetBackgroundDrawable(gd);
}
iOS:
if (Control != null)
{
if (e.NewElement != null)
e.NewElement.SizeChanged += (obj, args) =>
{
var borderLayer = new CALayer();
borderLayer.Frame = new CoreGraphics.CGRect(0, 0, this.Control.Frame.Width, this.Control.Frame.Height);
borderLayer.BackgroundColor = UIColor.Clear.CGColor;
borderLayer.BorderColor = UIColor.Gray.CGColor;
borderLayer.BorderWidth = 2;
borderLayer.CornerRadius = 10;
this.Control.TextField.BorderStyle = UITextBorderStyle.None;
this.Control.Layer.AddSublayer(borderLayer);
};
} |
Sample Link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/CustomRenderer1163330518
Screenshot:
Please check with the sample and let us know if you have any concern.
Regards,
Muneesh Kumar G
BH
Bharath
August 21, 2019 10:05 AM UTC
I have tried with your same example for sfautocomplete control. That underline is still showing. @Muneesh Kumar
protected override void OnElementChanged(ElementChangedEventArgs<SfAutoComplete> e) { base.OnElementChanged(e); if (Control != null) { //Control.Background = Context.GetDrawable(Resource.Drawable.rounded_corners); GradientDrawable gd = new GradientDrawable(); gd.SetShape(ShapeType.Rectangle); gd.SetColor(Android.Graphics.Color.Transparent); gd.SetCornerRadius(15); gd.SetStroke(4, Android.Graphics.Color.LightGray); //Control.AutoEditText.SetBackgroundColor(Android.Graphics.Color.Transparent); Control.SetBackgroundDrawable(gd); } }
MK
Muneesh Kumar G
Syncfusion Team
August 21, 2019 11:54 AM UTC
Hi Bharath,
To remove the underline, you have to set the ShowBorder API as false in SfAutoComplete. Please have the code snippet and sample from the below link,
Code Snippet:
|
ShowBorder="False"
|
Sample Link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/CustomRenderer1163330518
Screenshot:
Please check with the sample and let us know if you have any concern.
Regards,
Muneesh Kumar G
BH
Bharath
August 22, 2019 12:08 PM UTC
Thank you it worked for me..
MK
Muneesh Kumar G
Syncfusion Team
August 22, 2019 12:11 PM UTC
Hi Bharath,
Thanks for the update.
We are glad to know that the given solution works. Please let us know if you need any further assistance.
Thanks,
Muneesh Kumar G.
SIGN IN To post a reply.
- 5 Replies
- 2 Participants
-
BH Bharath
- Aug 21, 2019 06:27 AM UTC
- Aug 22, 2019 12:11 PM UTC