Pad*_*ySo 6 android dimensions dimension android-constraintlayout
Heyho伙伴,
目前我正在使用新的ConstraintLayout学习Android Studio 的新布局编辑器.
顺便说一句,我讨厌它.
但是我遇到了问题,如果我想用@dimen指定layout_height,它会被替换为dp值.
有人得到了这个问题吗?
Android Studio版本2.2.2和2.2.3相同的问题.
最新的gradle版本.
先谢谢你们!
编辑:
代码示例:
<?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>
Run Code Online (Sandbox Code Playgroud)
也在scrollview外面发生.
事实证明这是一个错误,并将在 Android Studio 2.3 中修复。
我认为这背后的原因是,ConstraintLayout 作为所见即所得布局不可避免地只能在可视化编辑器中进行编辑/操作。
因此,在dimens.xml中保留对dimens的引用意味着一旦您更改某些内容,移动一些元素,这些元素将不再相关,因此会被“实际当前值”替换。
也如文档中提到的:
该工具提供的所有边距均为 8dp,以帮助您的视图与 Material Design 的 8dp 方形网格建议保持一致。
| 归档时间: |
|
| 查看次数: |
844 次 |
| 最近记录: |