TextView не отображается в линейном макете - PullRequest
0 голосов
/ 08 февраля 2019

У меня есть три TextView, которые я хочу разместить внутри линейного макета.Когда я делаю это, текстовые поля исчезают на экране.Они появятся снова, если я возьму их из линейного макета и, например, поместу в относительный макет.

Ниже приведен код из моего линейного макета:

<?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>

Я не знаюЯ не понимаю, почему это происходит.Кто-нибудь может мне помочь?

1 Ответ

0 голосов
/ 08 февраля 2019

В вашем LinearLayout высота макета ограничена 350dp, и у вас есть ImageView с соответствующим родительским элементом в макете.Попробуйте сделать высоту LinearLayout равной wrap_content или установить фиксированную высоту для 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" />
...

ИЛИ

...

<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" />
...
...