ViewStub 布局垂直偏差不会将 viewstub 向下移动
ViewStub layout vertical bias doesn't move the viewstub down
我有一个约束布局,里面有一个 ViewStub。我已经向 viewStub 添加了约束。但是,我想将它向下移动一点,我尝试使用垂直偏移,但它根本没有移动。知道为什么吗?
这是我的 Viewstub
<ViewStub
android:id="@+id/no_data_viewstub"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout="@layout/no_data_layout"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cardView2"
app:layout_constraintVertical_bias="0.71000004" />
这是我在视图栏中使用的布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:layout_marginBottom="16dp"
android:fontFamily="@font/montserrat_medium"
android:text="@string/oops"
android:textColor="@color/azure"
android:textSize="24sp" />
<ImageView
android:id="@+id/imageView11"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_nodata" />
<TextView
android:id="@+id/textView38"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="16dp"
android:fontFamily="@font/montserrat_medium"
android:gravity="center"
android:text="@string/no_data"
android:textColor="@color/error_massage"
android:textSize="18sp" />
</LinearLayout>
我发现这是一个简单的错误。视图存根高度不能匹配约束。
为了改变偏见,它需要有一个高度的包装内容。
我有一个约束布局,里面有一个 ViewStub。我已经向 viewStub 添加了约束。但是,我想将它向下移动一点,我尝试使用垂直偏移,但它根本没有移动。知道为什么吗?
这是我的 Viewstub
<ViewStub
android:id="@+id/no_data_viewstub"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout="@layout/no_data_layout"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cardView2"
app:layout_constraintVertical_bias="0.71000004" />
这是我在视图栏中使用的布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:layout_marginBottom="16dp"
android:fontFamily="@font/montserrat_medium"
android:text="@string/oops"
android:textColor="@color/azure"
android:textSize="24sp" />
<ImageView
android:id="@+id/imageView11"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_nodata" />
<TextView
android:id="@+id/textView38"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="16dp"
android:fontFamily="@font/montserrat_medium"
android:gravity="center"
android:text="@string/no_data"
android:textColor="@color/error_massage"
android:textSize="18sp" />
</LinearLayout>
我发现这是一个简单的错误。视图存根高度不能匹配约束。
为了改变偏见,它需要有一个高度的包装内容。