【发布时间】:2020-12-20 23:10:02
【问题描述】:
我有一个带有不同视图的 LinearLayout,它在我的手机中安装时可以正常显示。但是我想将该 LinearLayout 放入一个 ContraintLayout,但是当我这样做时,我的屏幕上什么都没有显示。
这段代码运行良好
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
</data>
<LinearLayout
android:id="@+id/bottomMenu"
android:layout_width="match_parent"
android:layout_height="@dimen/short_cuts_bottom_menu_layout_height"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<!-- Views -->
</LinearLayout>
</layout>
但这不起作用
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/bottomMenu"
android:layout_width="match_parent"
android:layout_height="@dimen/short_cuts_bottom_menu_layout_height"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<!-- Views -->
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
我只是将我的 LinearLayout 放入 ConstraintLayout
有人知道为什么会这样吗?
【问题讨论】:
标签: android android-linearlayout android-constraintlayout