Android Development Knowledge Points Summary

Source: Internet
Author: User

Summarize the experience in project development, reduce the occurrence of similar situation, improve the development efficiency:

Example:

First, the layout file for TextView set textcolor and background color differences:

Background corresponds to selector:


TextColor corresponding to the selector:


Distinguish the difference O (∩_∩) o~, avoid wasting unnecessary development time ~ ~


Second, radiogroup+fragment write bottom navigation, radiogroup in the RadioButton can not modify the size of the Drawabletop picture:

I don't think the size of the four icons on the side is appropriate, but it doesn't change the size.



The following setbounds method can roughly resolve the problem, but may not be the best solution.

Displaymetrics dm = new Displaymetrics (); This.getwindowmanager (). Getdefaultdisplay (). Getmetrics (DM); int width = Dm.widthpixels;int height = dm.heightpixels;if (width <= 854 && height <= 480) {size =,} else if (Width & lt;= && Height <= 720) {size = $;} else {size = 70;} RADIOBTN1 = (RadioButton) radiogroup.getchildat (0); image1 = This.getresources (). Getdrawable (R.drawable.btn_selector _compete); image1.setbounds (0, 0, size, size), Radiobtn1.setcompounddrawables (null, image1, NULL, NULL); radioBtn2 = ( RadioButton) Radiogroup.getchildat (1); image2 = This.getresources (). getdrawable (R.drawable.btn_selector_message); Image2.setbounds (0, 0, size, size); Radiobtn2.setcompounddrawables (null, image2, NULL, NULL); radioBtn3 = (RadioButton) Radiogroup.getchildat (2); image3 = This.getresources (). getdrawable (r.drawable.btn_selector_home_unpressed); Image3.setbounds (0, 0, size, size); Radiobtn3.setcompounddrawables (null, IMAGE3, NULL, NULL); radioBtn4 = (RadioButton) Radiogroup.geTchildat (3); image4 = This.getresources (). getdrawable (R.drawable.btn_selector_discovery); image4.setbounds (0, 0, Size, size), Radiobtn4.setcompounddrawables (null, IMAGE4, NULL, NULL), RadioBtn5 = (RadioButton) Radiogroup.getchildat ( 4); image5 = This.getresources (). getdrawable (r.drawable.btn_selector_myself); image5.setbounds (0, 0, size, size); Radiobtn5.setcompounddrawables (NULL, IMAGE5, NULL, NULL);

If there is a better solution, please leave a message oh ~




Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Android Development Knowledge Points Summary

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.