Set the View to display only the transparent bottom border, transparent background box, and shadow background box.

Source: Internet
Author: User

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;}}


 


 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.