【发布时间】:2019-02-10 13:33:31
【问题描述】:
我的应用程序中的相对布局下方有一个线性布局。它们包含在约束布局和滚动视图中。
很遗憾,我的一个线性布局没有出现在我的屏幕上。
下面是我的代码,为了更清楚,我把TextViews等一些项目去掉了。
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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="match_parent"
tools:context=".ViewSingleClub">
<ScrollView
android:layout_width="match_parent"
android:layout_height="444dp"
android:layout_marginTop="68dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout_editor_absoluteX="4dp"
tools:layout_editor_absoluteY="68dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="150dp"
android:background="@drawable/gradientsbackground"
android:orientation="vertical"
android:gravity="center"
android:visibility="visible">
//items inside here
</LinearLayout>
<android.support.v7.widget.CardView
android:layout_width="270dp"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="100dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="4">
//items inside here
</LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
//This layout and everything inside doesn't appear
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="45dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
//items inside here
</LinearLayout>
</LinearLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>
谁能帮我弄清楚为什么这个线性布局不可见?
【问题讨论】:
-
在 Android Studio 的预览部分不可见?或者在运行应用程序时?
-
检查滚动视图顶部突出显示的错误“一个滚动视图只能有一个孩子”
-
预览中!
-
啊,对伊万很感兴趣..谢谢你。你会建议把所有东西都放在一个线性布局中吗?
-
我会在 ScrollView 中包装所有内容,包括 ConstraintLayout
标签: android android-layout android-linearlayout