TableView icon indicating copy to clipboard operation
TableView copied to clipboard

Layout Bug on Android < API18

Open Zardozz opened this issue 3 years ago • 1 comments

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));`

Zardozz avatar Nov 11 '20 23:11 Zardozz

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.

MGaetan89 avatar Apr 08 '21 15:04 MGaetan89