question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MaterialTextField setting background to Transparent not working

See original GitHub issue

🐛 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:

  • 📱 iOS
  • 🤖 Android
  • 🏁 WPF
  • 🌎 UWP
  • 🍎 MacOS
  • 📺 tvOS
  • 🐒 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

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
yasserjaroufcommented, Jan 22, 2021

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

1reaction
softlioncommented, Sep 22, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

MaterialUI TextField : changing background color is not ...
I'm trying to set the background color for TextField components in the app I'm working on, however it seems that when I add ......
Read more >
[TextInputLayout] Background can't be set to transparent ...
Setting colorSurface to transparent makes it so the background is not opaque. To change the actual color you have to change boxBackgroundColor. In...
Read more >
TextInputLayout
This allows TextInputLayout to set the EditText 's background to an outlined or filled box, respectively. Note: The actual view hierarchy ...
Read more >
Photoshop 22.x background transparency not work wi...
I'm tryng to modificate or create psd files with transparent artboard, but i show aalways a blank backround, even if transparent background is...
Read more >
Text fields - Material Design
Text fields let users enter, edit, and select text.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found