0

Need to create a table of TextViews with Kotlin, with different borders colors for the cells` and for the table, something similar to this.

I tried using TableLayout and TableRow and use different background colors for cells and table, but now I need the colors between the cells o to be different. How can this be achieved?

Samp
  • 9
  • 7
  • https://stackoverflow.com/questions/2108456/how-can-i-create-a-table-with-borders-in-android Take a look here. – Al-Amin Jul 25 '19 at 12:33

1 Answers1

0

You need to make different shape drawables like this

<item>
    <shape android:shape="rectangle" >
        <padding
            android:left="2dp"
            android:top="2dp" />
        <solid android:color="@android:color/holo_red_dark" />
    </shape>
</item>
<item>
    <shape android:shape="rectangle" >
        <padding android:right="2dp" />

        <solid android:color="@android:color/holo_blue_dark" />
    </shape>
</item>
<item>
    <shape android:shape="rectangle" >
        <padding android:bottom="2dp" />

        <solid android:color="@android:color/white" />
    </shape>
</item>
<item>
    <shape android:shape="rectangle" >
        <solid android:color="@android:color/holo_green_light" />
    </shape>
</item>

to give different color on different edges and use linearlayout with buttons to make proper table layout

Sagar gujarati
  • 152
  • 1
  • 15
  • Thanks for your answer. But how about doing it programmatically? since the number of rows and columns not defined, and the colors can change dynamically. – Samp Jul 25 '19 at 13:16