cancel
Showing results for 
Search instead for 
Did you mean: 

TouchGFX Scroll List not spacing properly

KDubo
Associate II

I want to create a scrollable list of menu item, If I understand correctly, a List can be scrolled when placed inside a Scrollable container and the add property can be used within the list class to add children which will then populate and the list and space automatically. I have defined my basic layout as a custom container and would like to populate the list based on my custom container as shown in the example at the bottom here: https://support.touchgfx.com/docs/development/ui-development/ui-components/containers/list-layout. The issue I keep running into is that when I add more than 1 element to the list, they overlap on top of each other instead of stacking vertically to form a list. I am able to remove the elements individually after they have been added so that would imply it's not a drawing issue, but an element spacing issue.

The code I use to add the elements within void InfoScreenView::setupScreen():

listElements[0].updateScrollIcon(0);
listElements[1].updateScrollIcon(1);
OptListCont.invalidate();

updateScrollIcon function updates the text and image within each element:

void SettingScrollElement::updateScrollIcon(int16_t index)
{
	switch(index)
	{
		case 0:
			//Update Icon
			MenuIcon.setBitmap(touchgfx::Bitmap(BITMAP_INFO_ICON_ID));
			//Update Text
			Unicode::strncpy(MenuItemBuffer, "INFO", 5);
			MenuItem.resizeToCurrentTextWithAlignment();
			MenuItem.invalidate();
			break;
		case 1:
			//Update Icon
			MenuIcon.setBitmap(touchgfx::Bitmap(BITMAP_GEAR_ICON_ID));
			//Update Text
			Unicode::strncpy(MenuItemBuffer, "SETTINGS", 9);
			MenuItem.resizeToCurrentTextWithAlignment();
			MenuItem.invalidate();
			break;
		case 2:
			//Update Icon
			MenuIcon.setBitmap(touchgfx::Bitmap(BITMAP_MOME_LOGO_ID));
			//Update Text
			Unicode::strncpy(MenuItemBuffer, "ABOUT", 6);
			MenuItem.resizeToCurrentTextWithAlignment();
			MenuItem.invalidate();
			break;
	}
}

I know I am missing something but I am having trouble finding the answers in the API guide. Thanks in advance!

1 REPLY 1
Romain DIELEMAN
ST Employee

Hi,

Were you able to find a solution to your issue ? Did you use the UI template "List Layout example" as reference/inspiration for your settings and code ?

/Romain