我正在使用constraintLyout v 1.0.1.
我想在我的xml中包含一个与我的全局布局的一部分相对应的子ConstraintLayout(它本身就是一个ConstraintLayout).我将布局分成两个xml,以便在其他地方使用此子部分
我尝试了这个但是我无法控制将子约束布局放在父级中的位置.我想知道是否必须将所有内容放在同一个xml文件中,或者它们是否是使用单独文件的解决方案.
tmp_1.xml
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LABEL1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="16dp"
/>
<TextView
android:id="@+id/label_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LABEL2"
app:layout_constraintStart_toStartOf="@id/label"
app:layout_constraintEnd_toEndOf="@id/label"
app:layout_constraintTop_toBottomOf="@id/label"
android:layout_marginTop="16dp"
/>
<include layout="@layout/tmp_2" />
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
tmp_2.xml
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/view_80"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="80th element"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="10dp"
android:layout_marginStart="12dp"
/>
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
结果是此实际结果
但我希望它成为预期的结果
我试过这个,但它不起作用
<include
app:layout_constraintTop_toBottomOf="@id/label_2"
layout="@layout/tmp_2" />
Run Code Online (Sandbox Code Playgroud)
我很乐意有你的解决方案,
谢谢
上下文:
macOS Catalina 10.15.6
Java 1.8.0_161
将 Android Studio 4.2 Canary 7 更新为 Canary 8(以及 Canary 9)后,无法再打开它。
我已经尝试从 Android Studio 官方网站和 JetBrains 的 Toolbox 应用程序安装它。在任何情况下都会发生相同的行为:
尝试启动 Android Studio 时没有任何反应。它甚至不显示“SplashScreen”的东西。
使用命令行启动应用程序时,出现一个可能有用的错误:
> open [...]/Android\ Studio\ 4.2\ Preview.app
LSOpenURLsWithRole() failed with error -10810 for the file [...]/Android Studio 4.2 Preview.app.
Run Code Online (Sandbox Code Playgroud)
我在互联网上看到这可能意味着该应用程序没有启动的适当权限。使用以前版本的 Android Studio Canary,我从未更改过任何权限,为什么现在呢?
假设我有一个像这样的可组合:
@Composable
fun LoadingButton() {
val (isLoading, setIsLoading) = state { false }
Button(
onClick = setIsLoading,
text = {
if (isLoading) {
Text(text = "Short text")
} else {
Text(text = "Very very very long text")
}
}
)
}
Run Code Online (Sandbox Code Playgroud)
如何为按钮的宽度更新设置动画?
我很清楚我可以向按钮添加一个 preferredWidth 修饰符,并使用以下方法为该宽度设置动画:
val buttonWidth = animate(target = if (isLoading) LoadingButtonMinWidth else LoadingButtonMaxWidth)
Run Code Online (Sandbox Code Playgroud)
但这不是我想要的。我需要为自动“包装内容”宽度设置动画。
提前致谢。