Android uses size resources Dimens

Source: Internet
Author: User

Sometimes the project needs to modify the distance-related properties of the widget's controls, just modify the values defined in the Dimens referenced by Wdiget. All references to it will be automatically modified in this way, thus achieving easy maintenance. Under the Values folder, create a file named Dimens.xml, as follows:

<?xml version= "1.0" encoding= "Utf-8"?> <resources>         <string name= "test_dimen" > Text area </string >     <string name= "Test_dimen1" > Buttons </string>       <dimen name= "Text_width" >150px</dimen >     <dimen name= "text_height" >100px</dimen>     <dimen name= "Btn_width" >30mm</dimen >     <dimen name= "Btn_height" >10mm</dimen>     

Call:

<textview           android:text= "@string/test_dimen"           android:id= "@+id/mydimentextview01"           android:layout_ Width= "Wrap_content"           android:layout_height= "wrap_content"           android:width= "@dimen/text_width"           android:height= "@dimen/text_height"           android:background= "@color/red_bg"   

Generally in the values folder of XML are categorized, Dimens.xml file only put dimen attributes of the label, easy to read and maintain.

Android uses size resources Dimens

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.