Get the bottom border for TableLayout, which is used as a row in a ListView

According to the Android aspect of open one-way traffic, there are two 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 what I want, since I only need a lower bound. Therefore, 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, when choosing a list TableRow will not be highlighted with the ListView selection color, since its background is already captured by the "# 000000" layer.

Is there a better way to have a lower border, but it will obey the color of the selection of the ListView ?

+6
source share
1 answer

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

+1
source

Source: https://habr.com/ru/post/921216/


All Articles