Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15495] Android: ListView doesn't correctly adhere to the Holo theme

GitHub Issuen/a
TypeBug
PriorityLow
StatusOpen
ResolutionUnresolved
Affected Version/sRelease 3.1.1, Release 3.1.3
Fix Version/sn/a
ComponentsAndroid
Labelsandroid, holo, listview, tableview, theme
ReporterTijs Zwinkels
AssigneeUnknown
Created2013-08-09T09:34:25.000+0000
Updated2018-09-28T15:06:27.000+0000

Description

Problem Description

When using a ListView on Android with a Holo theme, there are discrepancies between how the TableView was originally displayed, and how the ListView is displayed. This is especially apparent in the section-titles, and in buttons on a table-view row, neither of which seem to change when the theme changes. See the attached screenshots.

Steps to reproduce

1. Create a new mobile project 2. Import the attached test case 3. Click in the tab 1, should show you a tableview 4. Click in the tab 2, should show you the same data, but implemented in a listview. 5. The theme in both cases should be the same, but it's different.

Extra info

I have attached a test-project to demonstrate this issue. The app has two tabs, one containing a TableView, and one containing a ListView. Both tables have a similar buildup and should look identical. However, they don't. The project in the zip-file contains a git repository. Switch between different commits to view the issue in the default theme, holo dark (currently selected) and holo light.

Attachments

FileDateSize
Listview_theming.patch2013-09-13T15:47:18.000+00003888
ListViewTheming.zip2013-08-09T09:34:25.000+00005632237
Screenshot_2013-08-09-09-54-00.png2013-08-09T09:34:25.000+000078181
Screenshot_2013-08-09-09-54-04.png2013-08-09T09:34:25.000+000085923

Comments

  1. Tijs Zwinkels 2013-09-13

    I've attached a patch to titanium_mobile that solves the problem of the switch theming for me. Instead of creating the switch programatically, I'm now using the inflater to create the switch from a .xml file (the same way that Listview-items are created). For some reason, this causes the button to be themed correctly. However, this patch is not pull-request material: - I'm still not sure what the underlaying issue is here. Even in the old (non-working) case; Buttons are created in the same way, and since theming in Android should be hierarchical, I think they should have the same theme. I'm not sure why this works, and the old code didn't. - Right now, the 'SWITCH_STYLE_CHECKBOX' is created in a different way than the 'SWITCH_STYLE_TOGGLEBUTTON', but I can rectify that if required. - I haven't overridden the 'onLayout' method that was originally overridden. This doesn't seem to cause problems for me, but it might for you. If you need to theme the section-header, that's a bit simpler. 1) Build the android app 2) Create a platform/android/res/layout directory in the root of your project. 3) Copy build/android/res/layout/titanium_ui_list_header_or_footer.xml into the newly created directory. Now, the theming of the header and footer can be customised by editing the .xml file.

JSON Source