我的应用程序中的相对布局下面有一个线性布局。它们包含在Constraint布局和Scrollview中。
不幸的是,我的一个线性布局没有出现在我的屏幕上。
下面是我的代码,我已经取出了一些像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.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">
<ScrollView
android:layout_width="match_parent"
android:layout_height="444dp"
android:layout_marginTop="68dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<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:gravity="center"
android:orientation="vertical"
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>
<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>
</LinearLayout>
</ScrollView>