[TIMOB-15495] Android: ListView doesn't correctly adhere to the Holo theme
GitHub Issue | n/a |
Type | Bug |
Priority | Low |
Status | Open |
Resolution | Unresolved |
Affected Version/s | Release 3.1.1, Release 3.1.3 |
Fix Version/s | n/a |
Components | Android |
Labels | android, holo, listview, tableview, theme |
Reporter | Tijs Zwinkels |
Assignee | Unknown |
Created | 2013-08-09T09:34:25.000+0000 |
Updated | 2018-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
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.