嘿嘿小伙伴们,
目前我正在学习新的布局编辑器Android Studio 与新的约束布局.
顺便说一句,我讨厌它。
但我遇到了一个问题,如果我想指定一个布局高度 with @dimen,得到replaced with a dp值代替。
还有人遇到这个问题吗?
Android Studio 版本 2.2.2 和 2.2.3 同样的问题。
最新的 gradle 版本。
预先感谢各位!
Edit :
代码示例:
<?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>
也发生在滚动视图之外。
事实证明这是一个错误,并将在 Android Studio 2.3 中修复。 https://code.google.com/p/android/issues/detail?id=222019
我认为这背后的原因是,ConstraintLayout 作为所见即所得布局不可避免地只能在可视化编辑器中进行编辑/操作。
因此,在dimens.xml 中保留对dimens 的引用意味着一旦您更改某些内容、移动一些元素,这些元素将不再相关,因此将被替换为“实际当前值”。
也正如文中提到的docs https://developer.android.com/training/constraint-layout/index.html#adjust-the-view-margins:
该工具提供的所有边距均为 8dp,以帮助您的视图与 Material Design 的 8dp 方形网格建议保持一致。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)