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