Set view to show only transparent bottom border, transparent background frame, shaded background box method

Source: Internet
Author: User

The effect of the implementation is as follows:

The following code is the implementation of a bounding XML, 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>


Below is the XML that shows only the bottom 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>


Here is the background showing 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        Oid:color= "#BBB"/> <corners android:radius= "5dp"/> </shape> </item>             <!--white Top color-to <item android:bottom= "3px" > <shape android:shape= "Rectangle" > <solid android:color= "#FFE0EEEE"/> <corners android:radius= "5DP"/> <p                Adding android:top= "15DP" android:right= "15DP" android:bottom= "15DP" android:left= "15DP"/> </shape> </item></layer-list> 


Click to set their background color:

public void OnClick (View v) {switch (V.getid ()) {r.id.btnshowcounttimer:new Mycounttimer (120000, +, Btnshowcount Timer). 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;}}



Set view to show only transparent bottom border, transparent background frame, shaded background box method

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.