android - ViewStub 布局垂直偏差不会将viewstub 向下移动
问题描述
我有一个约束布局,里面有一个 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>
解决方案
我发现这是一个简单的错误。视图存根高度不能匹配约束。
为了改变偏差,它需要有一个高度的包装内容。
推荐阅读
- python - 如何使用 SQLAlchemy ORM 将孩子从一个父母复制到另一个父母?
- python - Tensorflow中的复值分布?
- roslyn-code-analysis - GetChangedDocumentAsync 返回 null 但应该有一个值
- rust - 是否可以连接迭代器?
- arrays - 根据字符串输出引用数组
- flutter - 如何使用 Flutter 实现像 Instagram live 这样的直播?
- python - 如何在 tkinter gui 上设置轮流(人类与计算机)玩 tictactoe?
- sysml - 使用 SysML 中的接口模块对信号进行建模
- swift - 斯威夫特:类型别名和关联类型与协议中的值有什么区别?
- c# - 编译器错误地指示使用未分配的局部变量错误