Set the View to display only the transparent bottom border, transparent background box, and shadow background box.
The implementation result is as follows:
The following code implements an xml with a border, which is very common.
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="@android:color/transparent" /><stroke android:width="1dp" android:color="#FFFF0000" /> <corners android:radius="0dp" /></shape>
The following shows only the xml of the lower border
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="@android:color/transparent" /><stroke android:width="1dp" android:color="#FFFF0000" /> <corners android:radius="0dp" /></shape>
The following is the background of the shadow effect.
<?xml version="1.0" encoding="utf-8"?><layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <!-- Bottom 2dp Shadow --> <item> <shape android:shape="rectangle"> <solid android:color="#BBB" /> <corners android:radius="5dp" /> </shape> </item> <!-- White Top color --> <item android:bottom="3px"> <shape android:shape="rectangle"> <solid android:color="#FFE0EEEE" /> <corners android:radius="5dp" /> <padding android:top="15dp" android:right="15dp" android:bottom="15dp" android:left="15dp"/> </shape> </item></layer-list>
Click set their background color:
public void onClick(View v) {switch (v.getId()) {case R.id.btnShowCountTimer :new MyCountTimer(120000, 1000, btnShowCountTimer).start();break;case R.id.btnBgBoard :btnBgBoard.setBackgroundResource(R.drawable.board);break;case R.id.btnOnlyShowLineBottom :btnOnlyShowLineBottom.setBackgroundResource(R.drawable.board_only_bottom_line);break;case R.id.btnShowLayers :btnShowLayers.setBackgroundResource(R.drawable.board_layers);break;default :break;}}