I have three TextViews which I want to place inside a Linear Layout. When I do this, the TextFields disappear on the screen. They reappear if I take them out of the Linear Layout, and put them into the Relative Layout, for example.
Below is the code from my Linear Layout:
<?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">
<Button
android:id="@+id/btnViewAllClubs"
android:layout_width="177dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:text="Clubs"
android:textAllCaps="false"
android:textSize="18sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="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">
<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="350dp"
android:background="@drawable/gradientsbackground"
android:orientation="vertical"
android:visibility="visible">
<ImageView
android:id="@+id/imgView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
tools:layout_editor_absoluteX="4dp"
tools:layout_editor_absoluteY="68dp" />
<TextView
android:id="@+id/txtClubName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Club Name"
android:textColor="#fff"
android:textSize="36sp"
android:textStyle="bold"
tools:layout_editor_absoluteX="4dp"
tools:layout_editor_absoluteY="68dp" />
<TextView
android:id="@+id/txtClubDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:text="Club Description"
android:textColor="@color/common_google_signin_btn_text_dark_focused"
android:textSize="30sp"
tools:layout_editor_absoluteX="4dp"
tools:layout_editor_absoluteY="117dp" />
<TextView
android:id="@+id/txtClubEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Email"
android:textColor="@color/common_google_signin_btn_text_dark_focused"
android:textSize="24sp"
tools:layout_editor_absoluteX="4dp"
tools:layout_editor_absoluteY="157dp" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>
I don't understand why this is happening. Could anyone help me out?
In your LinearLayout, the layout height is restricted to 350dp, and you have an ImageView with match parent in the layout. Try to make the LinearLayout height to wrap_content, or set a fixed height for the ImageView.
...
<LinearLayout
android:layout_width="match_parent"
android:layout_height="350dp"
android:background="@drawable/bg_gradient"
android:orientation="vertical"
android:visibility="visible">
<ImageView
android:id="@+id/imgView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
tools:layout_editor_absoluteX="4dp"
tools:layout_editor_absoluteY="68dp" />
...
OR
...
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_gradient"
android:orientation="vertical"
android:visibility="visible">
<ImageView
android:id="@+id/imgView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
tools:layout_editor_absoluteX="4dp"
tools:layout_editor_absoluteY="68dp" />
...