evrencoskun / TableView

TableView is a powerful Android library for displaying complex data structures and rendering tabular data composed of rows, columns and cells.
MIT License
3.14k stars 454 forks source link

Layout Bug on Android < API18 #347

Open Zardozz opened 3 years ago

Zardozz commented 3 years ago

I think this is a bug in the Android itself and this is more of documentation of a work around.

If you create a TableView and set as the root view or as a child of a linear Layout either programmatically or via XML layout files on Android Emulators running API less than API 18 then the column header recyclerview does not get sized correctly.
The header column recyclerview is full functional just it size when there is not enough data to fill the screen width is shorter than the data it holds (i.e. the WRAP_CONTENT property on it is not working correctly), you can scroll the header to show all the content.

The fix is use inside of a RelativeLayout in xml or programmatically.

Example of Bug on API 15 Emulator

Screenshot_1605136010

Same code on API 18 Emulator Screenshot_1605136120

Code from Espresso test used to generate screen shots

`Activity activity = mActivityTestRule.getActivity();

    TableView tableView =
            new TableView(InstrumentationRegistry.getInstrumentation().getTargetContext());
    Assert.assertNotNull(tableView);

    SimpleTestAdapter simpleTestAdapter = new SimpleTestAdapter();
    Assert.assertNotNull(simpleTestAdapter);

    tableView.setAdapter(simpleTestAdapter);

    SimpleData simpleData = new SimpleData(5);

    simpleTestAdapter.setAllItems(simpleData.getColumnHeaders(), simpleData.getRowHeaders(),
            simpleData.getCells());

    mActivityTestRule.runOnUiThread(() -> activity.setContentView(tableView));`
MGaetan89 commented 3 years ago

I have the same issue on API 29. I don't think it's a size issue of the column header, rather a black rectangle that pops on top of the column header. Clicking on one of the column header makes the rectangle disappear. For me, the rectangle comes up when I refresh the data in the table.

I'll investigate more and try to submit a PR to fix that properly.