6

According to Open-sided Android stroke?, there are basically 2 ways to implement borders for TableLayout.

Use Stroke

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#00ffffff"/>
    <stroke android:width="1dp" android:color="#ffffff"/>
</shape>

enter image description here

However, this is not something which I want, as I only want bottom border. Hence, I try another alternative.

Use 2 layers

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- This is the line -->
<item>
      <shape>
            <solid android:color="#ffffff" />
      </shape>
</item>
<!-- This is the main color -->
<item android:bottom="1dp">
     <shape>
           <solid android:color="#000000" />
     </shape>
</item>
</layer-list>

enter image description here

However, during list view selection, the TableRow will not be highlighted with ListView selection color, as its background already take over by "#000000" layer.

Is there any better way I can have bottom border only, yet it will obey ListView selection highlight color?

Community
  • 1
  • 1
Cheok Yan Cheng
  • 47,586
  • 132
  • 466
  • 875

1 Answers1

1

In your shape file use <solid android:color="@android:color/transparent"/> instead <solid android:color="#00ffffff"/>

Maratu13
  • 25
  • 3