Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): fix ListView layout with header and footer only #14117

Merged
merged 6 commits into from
Sep 18, 2024

Conversation

m1ga
Copy link
Contributor

@m1ga m1ga commented Sep 17, 2024

There is an issue with ListView sections that don't have a content and only a header and footer:

Screenshot_20240917-211111

<Alloy>
	<Window>
		<ListView>
			<ListSection>
				<ListItem title="Item" />
				<ListItem title="Item" />
			</ListSection>

			<ListSection>
				<HeaderView>
					<View height="50" backgroundColor="#111">
						<Label>Section 2 : Header View - item height=0</Label>
					</View>
				</HeaderView>

				<ListItem height="0"/>

				<FooterView>
					<View height="25" backgroundColor="#444">
						<Label>Section 2 : Footer View</Label>
					</View>
				</FooterView>
			</ListSection>

			<ListSection>
				<HeaderView>
					<View height="50" backgroundColor="#111">
						<Label>Section 2 : Header View - no item</Label>
					</View>
				</HeaderView>

				<FooterView>
					<View height="25" backgroundColor="#444">
						<Label>Section 2 : Footer View</Label>
					</View>
				</FooterView>
			</ListSection>

			<ListSection>
				<FooterView>
					<View height="25" backgroundColor="#444">
            <Label>Section only footer View - no item</Label>
					</View>
				</FooterView>
			</ListSection>

			<ListSection>
        <ListItem title="Item from 4" />
        <ListItem title="Item from 4" />
				<FooterView>
					<View height="25" backgroundColor="#444">
            <Label>Section 4 only footer View - and items</Label>
					</View>
				</FooterView>
			</ListSection>

			<ListSection>
				<ListItem title="last Section Item 1" />
				<ListItem title="last Section Item 2" />
				<ListItem title="last Section Item 3" />
			</ListSection>
		</ListView>
	</Window>
</Alloy>

This PR will connect the footer top to the header bottom if there isn't any content:
Screenshot_20240917-210822

Current workaround: add <ListItem height="0"/>

@hansemannn
Copy link
Collaborator

cc @prashantsaini1 can you review?

Copy link
Contributor

@cb1kenobi cb1kenobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on Windows. Fix works as advertised. Thanks!

@hansemannn hansemannn merged commit 5ad1ac9 into master Sep 18, 2024
5 checks passed
@hansemannn hansemannn deleted the fixListViewTemplate branch September 18, 2024 07:42
@prashantsaini1
Copy link
Contributor

prashantsaini1 commented Sep 18, 2024

I noticed a major issue in recent changes regarding layout updates. I raised this PR to fix it properly. Hopefully we can test it there.

hansemannn pushed a commit that referenced this pull request Sep 22, 2024
* fix(android): fix ListView layout with header and footer only

* remove log

* Update android/modules/ui/src/java/ti/modules/titanium/ui/widget/listview/ListViewHolder.java

Co-authored-by: Chris Barber <[email protected]>

* rename variable

---------

Co-authored-by: Chris Barber <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants