2

platform app using Xamarin PCL project. I have created a button with image and no text.

 <Button Image="{DynamicResource ProfileImage}" Grid.Row="0" Grid.Column="2" BackgroundColor="Transparent" x:Name="dashboard" StyleId="dashboard" HorizontalOptions="Center" Clicked="TabClicked"></Button>

I am facing some UI Issue. In windows 10,it looks like -

enter image description here

In android, it looks like-

enter image description here

Is there any way to remove this outline border from android.

4
  • did you solve your problem? Commented Feb 17, 2017 at 15:33
  • Did you manage to solve your problem? Commented Mar 28, 2017 at 9:01
  • @Daniel yes but by setting buttons elevation to zero. Commented Mar 28, 2017 at 11:01
  • Add your answer and accept it. It may help some other people ;) Commented Mar 28, 2017 at 11:04

4 Answers 4

1

I removed the border/shadow from buttons in Android by setting its elevation to 0px with the help of this link

class MyButtonRenderer : ButtonRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
        {
            base.OnElementChanged(e);
            try
            {
                if (Control != null)
                {
                    Control.Elevation = 0;
                }
            }
            catch(Exception ex){}
        }
    }
Sign up to request clarification or add additional context in comments.

Comments

0

Have you tried setting BorderColor="Transparent" on your button XAML?

Comments

0

To remove background of an image completely, you can use Image view type instead of Button.

You can arrange it's source:

<StackLayout Padding="15,5,0,5">
      <Image x:Name="MyImage"  Source="myImage.png"/>
</StackLayout>

And you can add a click method it easily:

var gestureRecognizerForImage = new TapGestureRecognizer();
gestureRecognizerForImage.Tapped += MyImageClicked;
MyImage.GestureRecognizers.Add(gestureRecognizerForImage);

 public async void GetMediaClicked(object sender, EventArgs e)
 {
     await DisplayAlert("Clicked", "My Image is Clicked", "OK");
 }

Comments

0

You can set BorderWidth = 0. It should remove the border.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.