3

I have two TableLayouts next to each other. They display similar information so corresponding rows need to be next to each other. I.e. row three of the left table needs to be lined up horizontally with row three of the right table. (I'm using two tables so I can get a vertical line between them as well as some other reasons that make the code more organized.) When I started, both tables used TextViews within the TableRows to display the data and everything lined up nicely. Now, I need the table on the right to have checkmarks next to cells within TableRows to show they have been completed, so in the right table, I switched from TextViews to CheckedTextViews which works very nicely except they have a lot more white space between the rows than the table on the left which still uses TextViews. I've tried setting the padding to zero for the CheckedTextView and its drawable, but it doesn't seem to have any effect.

Here is the style I am applying to my CheckedTextViews:

<style name="Check" >
  <item name="android:layout_height">wrap_content</item>
  <item name="android:layout_width">wrap_content</item>
  <item name="android:gravity">center_vertical|left</item>
  <item name="android:drawablePadding">0dp</item>
  <item name="android:padding">0dp</item>
  <item name="android:checkMark">?android:attr/listChoiceIndicatorMultiple</item>
</style> 

Here is a sample row from my TableLayout:

<TableRow>
  <CheckedTextView 
    android:id="@+id/j_elective_01"
    style="@style/Check"/>

  <CheckedTextView 
    android:id="@+id/j_elective_02"
    style="@style/Check"/>
</TableRow>

I've considered the possibility that the icon used for the checkbox has a lot of builtin whitespace, I've looked at checkbox_on_background.png and checkbox_off_background.png in ...platforms/android-12/data/res/drawable-hdpi/ and that doesn't seem to be the case.

I want to avoid adding padding to the left table entries to line things up because I don't want to waste the screen space. I just want to find a way to get rid of some of the space between the rows in the right table.

jeff
  • 31
  • 2

1 Answers1

0

Change the size of the checkbox so it does not take up more space than your text:

android-how-to-change-checkbox-size

Community
  • 1
  • 1
CrackerJack9
  • 3,650
  • 1
  • 27
  • 48