XF-Material-Library icon indicating copy to clipboard operation
XF-Material-Library copied to clipboard

MaterialTextField setting background to Transparent not working

Open nicolasHul opened this issue 4 years ago • 8 comments

🐛 Bug Report

When setting the BackgroundColor to Transparent on a MaterialTextField the BackgroundColor is still filled with the default color, ignoring the Transparent property on Android. This is tested with a MaterialTextField inside a Grid with a Background image on Android. The Background image is a <Image> component with a rowspan of the total grid rows, and Aspect set to AspectFill. It is not (yet) tested on iOS.

I also tested it without the background image and it results in the same (the Transparent property being ignored).

Expected behavior

The Filled color should be transparent of the MaterialTextField and not default back to the #DCDCDC value.

Screenshots

image

XAML Code

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
    x:Class="PCS2.APP.Views.Login.LoginPage"
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:customControls="clr-namespace:PCS2.APP.CustomComponents;assembly=PCS2.APP"
    xmlns:d="http://xamarin.com/schemas/2014/forms/design"
    xmlns:material="clr-namespace:XF.Material.Forms.UI;assembly=XF.Material"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    Shell.FlyoutBehavior="Disabled"
    Shell.NavBarIsVisible="False"
    Shell.PresentationMode="ModalAnimated"
    Shell.TabBarIsVisible="False"
    mc:Ignorable="d">


    <ContentPage.Content>

        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="70" />
                <RowDefinition Height="70" />
                <RowDefinition Height="70" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>


            <Image
                x:Name="PCSBackground"
                Grid.Row="0"
                Grid.RowSpan="6"
                Aspect="AspectFill" />


            <Image
                x:Name="PCSLogo"
                Grid.Row="1"
                Aspect="AspectFit"
                HeightRequest="70" />


            <material:MaterialTextField
                Grid.Row="2"
                Margin="{StaticResource EntryMargin}"
                AlwaysShowUnderline="True"
                BackgroundColor="Transparent"
                InputType="Email"
                Placeholder="E-mail of gebruikersnaam"
                Text="{Binding Email}" />


            <material:MaterialTextField
                Grid.Row="3"
                Margin="{StaticResource EntryMargin}"
                AlwaysShowUnderline="True"
                BackgroundColor="Transparent"
                InputType="Password"
                Placeholder="Wachtwoord"
                Text="{Binding Password}" />


            <material:MaterialButton
                Grid.Row="4"
                Margin="30,16,30,80"
                BackgroundColor="#3880ff"
                Command="{Binding ExecuteLogin}"
                Text="Inloggen" />


        </Grid>
    </ContentPage.Content>
</ContentPage>

Configuration

Version: 1.7.4

Platform:

  • [ ] :iphone: iOS
  • [x] :robot: Android
  • [ ] :checkered_flag: WPF
  • [ ] :earth_americas: UWP
  • [ ] :apple: MacOS
  • [ ] :tv: tvOS
  • [x] :monkey: Xamarin.Forms

Additional information

  • Using Xamarin.Forms 4.8.0.1364
  • Using Xamarin.Essentials 1.5.3.2
  • Targeting framework: Android 10.0 (API Level 29 - Q)

Additional used libraries:

  • Splat 9.5.37

nicolasHul avatar Sep 09 '20 09:09 nicolasHul

same here, on IOs device

Alextorres950325 avatar Sep 09 '20 21:09 Alextorres950325

this issue need to be solved , I am also having the same problem in iOS device.

shubhamkumarnayak avatar Sep 16 '20 12:09 shubhamkumarnayak

Because the MaterialtextField Background binding is looking for a colour, it could be an issue with string interpolation. One potential fix could be to use a binding on the Background field and set it to Color.Transparent.

<material:MaterialTextField
                Grid.Row="2"
                Margin="{StaticResource EntryMargin}"
                AlwaysShowUnderline="True"
                BackgroundColor="{Binding BGColor"
                InputType="Email"
                Placeholder="E-mail of gebruikersnaam"
                Text="{Binding Email}" />

public Color BGColor {get; set} = Color.Transparent;

ske66 avatar Sep 17 '20 09:09 ske66

Maybe fixed by https://github.com/Baseflow/XF-Material-Library/pull/378 or https://github.com/Baseflow/XF-Material-Library/pull/379

softlion avatar Sep 20 '20 21:09 softlion

@divyesh008 if you read carefully you'll see that the pr are not merged yet.

softlion avatar Sep 22 '20 17:09 softlion

Dude you confused my world, don't use the BackgroundColor, use this: CardBackgroundColor="Transparent"

yasserjarouf avatar Jan 22 '21 14:01 yasserjarouf

@yasserjarouf CardBackgroundColor is not a property of MaterialButton

ske66 avatar Mar 31 '21 08:03 ske66

Downgrading XF to 5.0.0.2012 is a temporary workaround for me.

felipechavez avatar Sep 26 '21 15:09 felipechavez