3

I have some problem with setting params to my view in xml file with values from dimen files.

For example when i'm adding layout_height param to my EditText in laytout xml file:

    <EditText
     ....
    android:layout_height="@dimen/et_height" 
     ....
    />

File dimens:

<resources>
     .........
    <dimen name="example">16dp</dimen>
    <dimen name="et_height">20dp</dimen>
     .........
</resources>

It works fine. But sometimes when i open this file again AndroidStudio replace @dimen/et_height with value 20dp in layout xml file. And i must change it again to @dimen/et_height. How can i fix this ?

This is the normal case:

normal case

But in my case AndroidStudio replaces with value:

bad case

Vlad Morzhanov
  • 1,260
  • 3
  • 14
  • 29
  • 2
    it doesn't change the file, it just shows you the value – Blackbelt Dec 07 '16 at 14:40
  • just click at this value, and you will know why – Linh Dec 07 '16 at 14:42
  • 1
    Well i know that. In normal case param value change it color to gray and when i'm click at this value it replaces with @dimen/et_height. But sometimes AndroidStudio "replaces" @dimen/et_height link with value. Not just gray value. – Vlad Morzhanov Dec 07 '16 at 14:46
  • 1
    @VladMorzhanov Are you using the visual editor at all? If you are using that and dragging views around, Studio will update your XML files to reflect where you placed the views in the visual editor. – Bryan Herbst Dec 07 '16 at 14:53
  • Yes i'm using visual editor. But i'm not changing height value in editor. – Vlad Morzhanov Dec 07 '16 at 14:56
  • Problem in ConstraintLayout, it is not stable and have many bugs like this. – Vlad Morzhanov Dec 07 '16 at 15:05

1 Answers1

0

Having the same issue. Thought it is the ConstraintLayout but the issue also appears in every other layout though..

related post from me : Android ConstraintLayout @dimens replaced with hardcoded values

Also some other user said it just shows the dp value, i am completely in your situation i know the grey text, but it does really replace the value..

Community
  • 1
  • 1
PadySo
  • 55
  • 5
  • The only right decision i see here is to use hardcoded values in several layout files (like layout-hdpi, layout-xhdpi...) instead of several dimen files for one layout. – Vlad Morzhanov Dec 08 '16 at 22:31