Android Development-use Framelayout to implement icon middle display text

Source: Internet
Author: User

Requirement: The number of days in the Calendar feature to display the current date in an icon

First on:

650) this.width=650; "title=" QQ picture 20150422095814.jpg "alt=" wkiol1u3aascgolvaaau9znq4_w956.jpg "src="/http S3.51cto.com/wyfs02/m02/6b/c5/wkiol1u3aascgolvaaau9znq4_w956.jpg "/>

Key XML layout file:

<framelayout        android:layout_width= "Wrap_content"          android:layout_height= "Fill_parent"          android:layout_margin= "4DP"  >           <imageview            android:id= "@+id/ Itemimage "            android:layout_width=" Wrap_ Content "            android:layout_height=" Wrap_ Content "            android:layout_gravity=" center "            android:background=" @android:d rawable /ic_input_add " />        <TextView         &nBsp;    android:id= "@+id/tvdays"              android:layout_width= "Wrap_content"              android:layout_height= "Wrap_content"              android:layout_gravity= "Center"              android:background= "#00000000"              android:textcolor= "#FFFFFF"              Android:textsize= "18SP"             android:text= " Day "/>    </framelayout>

where android:layout_gravity= "center" centers the control, android:background= the "#00000000" setting TextView the background is completely transparent (translucent: android:background = "#e0000000")

Corresponding code in activity:

ImageView image = (ImageView) Itemview.findviewbyid (r.id.itemimage);   Image.setimageresource (iconID);   Set the image's padding image.setpadding (0, 0, 8, 0);   TextView Tvday = (TextView) Itemview.findviewbyid (r.id.tvdays);    Only the day of the list icon displays the number of days if (iconID = = R.drawable.today) {tvday.setvisibility (view.visible);    Tvday.setpadding (0, 0, 8, 0);   Tvday.settext (Currday);   }else{tvday.setvisibility (view.invisible); }

This article is from the "alan_y (upspringing)" blog, so be sure to keep this source http://alany.blog.51cto.com/6125308/1636770

Android Development-use Framelayout to implement icon middle display text

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.