Android ConstraintLayout @dimens replaced by hardcoded values

Heho's assistants,

I am currently studying a new layout editor for Android Studio with the new ConstraintLayout .

By the way, I hate him.

But I got a problem: if I want to specify layout_height with @dimen , it gets dp .

Has anyone else got this problem?

Android version 2.2.2 and 2.2.3.

New version of gradle.

Thanks in advance guys!

Edit:

Code example:

<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content"> <android.support.constraint.ConstraintLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageView android:layout_width="wrap_content" android:layout_height="@dimen/imageViewHeight" app:srcCompat="@drawable/accept" android:id="@+id/imageView" android:layout_marginStart="16dp" app:layout_constraintLeft_toLeftOf="parent" android:layout_marginLeft="16dp" android:layout_marginTop="16dp" app:layout_constraintTop_toTopOf="parent" /> </android.support.constraint.ConstraintLayout> </ScrollView> 

An external scrollview also occurs.

+6
source share
1 answer

It turns out that this is a bug and will be fixed in Android Studio 2.3.


I think the reason is that ConstraintLayout as a WYSIWYG layout inevitably needs to be edited / processed only in a visual editor.

Therefore, keeping reference to the dimensions in your dens.xml would mean that as soon as you change something, move some elements around, they will no longer be relevant and, therefore, will be replaced by "actual current values".

Also, as mentioned in the docs :

All fields offered by the tool are 8dp factors to help your views comply with the recommendations of the Material Design 8dp square grid.

+1
source

Source: https://habr.com/ru/post/1012973/


All Articles