考虑这个简单的ConstraintLayout content_main.xml
,其中一个View
是“常规”,而另一个View
从概念上讲是动画背景的一部分,但仍相对于常规View
进行布局:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#000">
<!--LinearLayout Fixes 'wrap_content' but breaks positioning
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"-->
<View
android:id="@+id/shouldBeExcludedFromWrapContent"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginTop="30dp"
app:layout_constraintTop_toBottomOf="@id/partOfWrapContent"
app:layout_constraintLeft_toRightOf="@id/partOfWrapContent"
android:background="@android:drawable/star_big_on" />
<!--/LinearLayout-->
<View
android:id="@+id/partOfWrapContent"
android:layout_width="300dp"
android:layout_height="300dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:background="@android:drawable/sym_action_call" />
</androidx.constraintlayout.widget.ConstraintLayout>
[C0中带有以下内容:
MainActivity.onCreate()
它产生以下动画( setContentView(R.layout.content_main)
findViewById<View>(R.id.shouldBeExcludedFromWrapContent)
.animate()
.rotationBy(5 * 360f)
.translationXBy(-900f)
.translationYBy(-900f)
.setDuration(5_000L)
.start()
和androidx.constraintlayout:constraintlayout:1.1.3
都出现:]
2.0.0-beta4
如何使计算忽略wrap_content
?我希望它被其父剪辑,所以最终结果是这样的:
@id/shouldBeExcludedFromWrapContent
[
ConstraintLayout
必须为android:layout_height
,因为实际代码将位于wrap_content
必须是
ScrollView
的官方问题跟踪程序的引用,或ConstraintLayout
源代码的引用,或 标题(或等同名称)中提出的问题的解决方案
ConstraintLayout