Wish xCustomListView - pressed color, line divider, item transparency issue

Peter Simpson

Expert
Licensed User
Longtime User
Hello Erel,
I'm going to presume that you're going to say that this is not an issue/bug and it's been posted on the forum before, I've searched and sadly I can't find it. I will ask for it as a wish, I would like the press color, line divider and item transparency all towork as one in unity.

I see how the line divider works is by simply turning the background color to the color of your choice (light gray in my case), then whilst adding each item a gap is left in between each item thus showing the line divider (the background color). I've sadly come across an issue with this.

If you use a line divider, what happens is that the app will start, it quickly shows a white background, then the background will quickly change to the color that you have chosen for the divider (light gray in my case), then the list will populate with the item which in my case has a white activity background. To get around the the one off light gray background flash is easy enough but I have to hide the scrollview, then populate it, then unhide the scroll view again using the xCLV.sv.Visible property, as the scrollview is what the items are being populated on.

The problem lies in the fact that if you want to use pressed color in the xCLV, the items you are adding to the list (xCLV) must be on a transparent activity in the designer, that makes sense to me. If you have the line divider as well, the line divider background (scrollview color) becomes the dominant color (light gray in my case) and you also lose lose the line divider and the list becomes the scrollview color. When the item activity has a transparent background the press color works but then you don't have line divider as the items being added are have a transparent activity and are now the same color as the background (light gray in my case).

Basically what I'm saying is that if you set the item activity colour to what is should be in my case (white), then you will get the line divider but the press color does not work. If you want press color to work, then your item activity color must be transparent but then you cant have an item line divider.

I have a strange feeling that I've come across this issue before a couple of years ago in an app that I didn't finish. I got around this issue in an unprofessional unorthodox way by using a 1dip/2dpi high colored panel on a transparent item activity (xCLV divider not used), which is not really the correct way to design a layout. It appears that the line divider property completely left my mind and it just became second nature for me to go straight to my nasty little hack as a line divider when using xCLV with lists, don't worry, my tutorial are using the line divider but no press color.

Please please pleeeeeeeeeeeeeeeeeeeeease tell me that I'm 100% incorrect and that I'm doing something wrong, tell me that there is an easier solution to getting all of the above working as one in unity.

Thank you
 

Peter Simpson

Expert
Licensed User
Longtime User
I've have also used a solution where every time I added a item to the list (xCLV), the odd numbered lines were a slightly different shade of color to the even numbered lines, but they still do not look right without a line divider, but the list does look better and the press color works with that solution.

The problem is that not all clients want to have a two tone list of items in their expensive bespoke software solutions.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I think that I understand and the solution is quite simple.

All you need to do is to set the items desired background color when you are adding the panels.
B4X:
Dim Pnl As B4XView = XUI.CreatePanel("")
Pnl.Color = XUI.Color_White '<--------
Pnl.SetLayoutAnimated(0, 0, 0, CLVList.AsView.Width, 50dip)

The issue you encounter is related to the lazy loading implementation.
When you add a new item to CLV, it gets the panel color and assigns this color to an internal panel. It then makes your panel transparent.
This effect is overridden when you later call LoadLayout. So the solution is to keep the item layout with transparent background and set the correct color when adding the "stub" items.
 

Peter Simpson

Expert
Licensed User
Longtime User
I think that I understand and the solution is quite simple.

That's it, it's easy when you know how @Erel šŸ‘
I have that memorised now, onward and upward it is then...

Wait a minute, isn't that line already in one of your code examples already, i definitely 100% recognise it @Erel, but where from?????????????
 
Top