Bug with ListView item background color on certain Android versions

0 Answers 107 Views
ListView
almostEric
Top achievements
Rank 1
Iron
Iron
almostEric asked on 24 May 2023, 02:51 PM

I have a listview using templatecells.

With android API >= 31, everything looks fine (default background is transparent)

On androd API 28, the background defaults to white, you can manually set it to other colors which work, but if set to transparent, the background stays white

Maria
Telerik team
commented on 26 May 2023, 10:21 AM

Hello Erin,

Could you please provide more details about where you set the BackgroundColor property? On the element inside the template cell, on the RadListView, or using the ItemStyle?  Could you provide a code snippet of how you defined the ListView in XAML?

Robert
Top achievements
Rank 1
commented on 21 Oct 2023, 11:05 PM

I am running into this as well, below is code for my listview, everything is listening to the color transparency except Each Listview item.


<telerik:TabViewItem ImageSource="messagecenter_received_on" >
    <telerik:RadListView ItemsSource="{Binding ReceivedItems}" BackgroundColor="Transparent">
        <telerik:RadListView.ItemTemplate>
            <DataTemplate x:DataType="local:Gift">
                <telerik:ListViewTemplateCell>
                    <telerik:ListViewTemplateCell.View>
                        <Grid ColumnDefinitions="100,*,50" RowDefinitions="40,50*" BackgroundColor="Transparent">
                            <Border Grid.RowSpan="2" Stroke="{StaticResource Gray100}" HorizontalOptions="Start" VerticalOptions="Center" StrokeThickness="4" WidthRequest="80" HeightRequest="80" StrokeShape="RoundRectangle 40">
                                <Border.Shadow>
                                    <Shadow Brush="Black" Offset="2,2"></Shadow>
                                </Border.Shadow>
                                <Image Source="{Binding SenderImage}" WidthRequest="100" HeightRequest="100" Aspect="AspectFill" HorizontalOptions="Center" VerticalOptions="Center"></Image>
                            </Border>
                            <Label Text="{Binding SenderUsername}" Grid.Column="1" FontSize="Large" VerticalOptions="End" />
                            <Label Text="{Binding createdAt}" Grid.Column="1" FontSize="Micro" Grid.Row="2" VerticalOptions="Start" />
                        </Grid>
                    </telerik:ListViewTemplateCell.View>
                </telerik:ListViewTemplateCell>
            </DataTemplate>
        </telerik:RadListView.ItemTemplate>
    </telerik:RadListView>
</telerik:TabViewItem>

 

Yana
Telerik team
commented on 24 Oct 2023, 12:38 PM

Hi Robert,

You would need to set the BackgroundColor through the ItemStyle property of the ListView like this:

 

<telerik:RadListView ItemsSource="{Binding ReceivedItems}" BackgroundColor="Transparent">
    <telerik:RadListView.ItemStyle>
        <telerik:ListViewItemStyle BackgroundColor="Transparent" />
    </telerik:RadListView.ItemStyle>
...
</telerik:RadListView>

 

Please give this a try and let me know if you still experience any issues.

No answers yet. Maybe you can help?

Tags
ListView
Asked by
almostEric
Top achievements
Rank 1
Iron
Iron
Share this question
or