我想将视图放置在ConstraintLayout
用滑动动画来制作它们的动画。我尝试过设置像这样的约束constraintBottom_toTopOf="parent"
但是View
留在容器内。
请注意,我希望通过使用内置动画的约束来实现此目的,而不是使用代码内动画。
知道我该怎么做吗?
我在用着compile 'com.android.support.constraint:constraint-layout:1.1.0-beta1'
使用 Android Studio 3.0 Beta 7
这是一个简单的 xml 文件,应将视图放置在容器之外:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/colorAccent">
<View
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@color/colorPrimary"
app:layout_constraintBottom_toTopOf="parent"/>
</android.support.constraint.ConstraintLayout>
But this is the result
这似乎是一个问题ConstraintLayout
1.1.0-beta1;它按预期工作ConstraintLayout
1.1.0-beta3。
更新至ConstraintLayout
1.1.0-beta3。我还要指出,您需要通过执行类似以下操作来水平限制您的视图。
<View
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@color/colorPrimary"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintBottom_toTopOf="parent" />
附带说明一下,负边距不被接受ConstraintLayout
. See this https://stackoverflow.com/questions/42984909/how-to-achieve-overlap-negative-margin-on-constraint-layout关于负边距的堆栈溢出问题和ConstraintLayout
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)