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