Values-dimen Resource Reference

Source: Internet
Author: User

Today, there is a situation, that is, at different resolutions below the need to set different distances, when the first reflection is to redefine a layout. However, it is obviously inappropriate to copy so much code just to change a value. It was then thought that it would be better to create different dimen at different resolutions. Of course, if you cut the picture well, it is not allowed to be so troublesome at all. Because of the different resolutions below, if you use DP, it will automatically convert to PX

Change as follows

#    Modified:   res/layout-port/simple_pad_vfive.xml#    new file:   res/values-hdpi/funui_dimens.xml#    new file:   res/values-xhdpi/funui_dimens.xml#    new file:   res/values-xxhdpi/funui_dimens.xml

Specific as follows

Create a different resolution directory

mkdir res/values-hdpi/;cd res/values-hdpi/;vim funui_dimens.xml

Funui_dimens.xml content is as follows

1<Resources>2<dimenname= "Equal_button_width">87.5dp</dimen>3<dimenname= "Equal_button_margin_right">-0.5dp</dimen>4</Resources>

The reference places are as follows

         <Com.android.calculator2.ColorButton161             android:id= "@+id/equal"  162             android:layout_marginright= "@dimen/equal_button_margin_right"163             Android:layout_width= "@dimen/equal_button_width"164             android:layout_height  = "158DP"165             android:layout_weight= "1"166             Myattr:textnumber = "@string/equal" />

Values-dimen Resource Reference

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.