Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Have bottom border for TableLayout which is used as row in ListView

Tags:

android

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?

like image 676
Cheok Yan Cheng Avatar asked Jul 24 '12 14:07

Cheok Yan Cheng


1 Answers

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

like image 117
Maratu13 Avatar answered Oct 07 '22 01:10

Maratu13