gpt4 book ai didi

android - app :layout_goneMarginLeft ="" do for views in constraintlayout? 是什么意思

转载 作者:行者123 更新时间:2023-12-03 22:48:28 24 4
gpt4 key购买 nike

app:layout_goneMarginLeft 如何及其变体会影响约束布局中的 View 排列?

最佳答案

这个概念的一个例子:
考虑2 TextViews带有 ID textView1textView2在哪里 textView2 textView1 末尾有 0 dp 约束.
案例 1:当 textView1 的可见性是 VISIBLE , textView2正好在 textView1 的右边0 dp 边距。

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="100dp">

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/form_field_background"
android:padding="5dp"
android:text="TextView1"
android:visibility="visible" />

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/form_field_background"
android:padding="5dp"
android:text="TextView2"
app:layout_constraintStart_toEndOf="@+id/textView1"
app:layout_goneMarginLeft="10dp"
app:layout_goneMarginStart="10dp" />

</android.support.constraint.ConstraintLayout>
结果
Enter image description here
案例 2:当 textView1 的可见性是 GONE , textView2将其 marginLeft 设置为 10 dp,因为我已指定 app:layout_goneMarginLeft="10dp"
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="100dp">

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/form_field_background"
android:padding="5dp"
android:text="TextView1"
android:visibility="gone" />

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/form_field_background"
android:padding="5dp"
android:text="TextView2"
app:layout_constraintStart_toEndOf="@+id/textView1"
app:layout_goneMarginLeft="10dp"
app:layout_goneMarginStart="10dp" />

</android.support.constraint.ConstraintLayout>
结果
Enter image description here

关于android - app :layout_goneMarginLeft ="" do for views in constraintlayout? 是什么意思,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51621712/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com