-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Bug] ItemsViewCell SelectedBackground shows Gray selected background even when content visual state has been overriden #7790
Comments
@newky2k There was a discussion on the selected item background color somewhere on Github, but I can't find it, particularly with respect to overriding Android's default style colors. @hartez Another approach here could possibly be adding content insets to CollectionView along with item spacing, which would not show the gray/orange selection colors(#7442), but it would restrict the tappable item area. I agree, however, that VSM should work as intended. |
On Android, you can make it transparent by setting |
@eli191 Ive followed as suggested in the docs on Xamarin using the visual state manage but doesnt work, I havnt been able to find work around yet. My problem is my background is a blurred image so I cannot simply change the row to the same as the background source. Below does not work: <VisualStateManager.VisualStateGroups>
<VisualStateGroup Name="CommonStates">
<VisualState Name="Normal" >
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="Transparent" />
</VisualState.Setters>
</VisualState>
<VisualState Name="Selected">
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="Transparent" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups> |
@LeoJHarris I ended up with
|
@eli191 I thought about doing that, not a biggie atm to have the gray background color on selected rows. We can wait it out if they fix this issue soon otherwise Ill look at implementing something similiar to that. |
This really needs fixing. |
Hi wondering if this will be fixed, whatever I do I cannot remove the gray background.Any suggestion |
#12651) fixes #7790 fixes #9590 fixes #11421 * Correction of CollectionView to work properly with selected item color when using VisualState on Android and iOS * Update TemplatedCell.cs * Update TemplatedItemViewHolder.cs * Add scaling to make the bug more obvious * Make fix work for on-template visual states on iOS * Make fix for for on-template visual states on Android * Minor performance optimization * Make method name more explicit * Spaces -> Tabs * Fix UI test failure (item 3 doesn't fit on the screen anymore) Co-authored-by: Rony Mesquita <ronymesquitadasilva@gmail.com>
Description
On iOS
When using a CollectionView, overriding the selected visual states of the DataTemplate content the Gray SelectBackgroundView is shown and cannot be hidden. A long press will show the Gray selectedbackground color, then the overridden one which looks odd.
Additionally, if the content doesn't fill the whole cell(such as using rounded corners) the gray background selection shows through on the unused space which looks bad(see below)
On Android
The same thing happens but it uses the system selection colour if the overriden background colour is Transparent.
The justification is that i want to handle the selection change within the visible content and there is no way to stop the full cell background colour(Gray on iOS and System colour on android) being shown and too leave selection to the templated content.
This is the code on iOS that is causing the problem
Xamarin.Forms/Xamarin.Forms.Platform.iOS/CollectionView/ItemsViewCell.cs
Lines 16 to 21 in 37c22eb
Steps to Reproduce
Expected Behavior
When the item is selected the unused background will not change colour
Actual Behavior
The unused background shows either Gray(iOS) and system color on Android
You could provide a property of CollectionView to set the selected item colour, or have some other way of disabling it. I could disable selection and add a tap gesture to the sub-views but that would be more work and would lose some of the benefits of CollectionView.
Basic Information
Screenshots
Reproduction Link
CollectionViewTest.zip
The text was updated successfully, but these errors were encountered: