簡體   English   中英

TextView不在線性布局中顯示

[英]TextView not showing up in Linear Layout

我有三個要放置在線性布局中的TextView。 當我這樣做時,TextFields消失在屏幕上。 例如,如果我將它們從“線性布局”中取出並放入“相對布局”中,它們就會重新出現。

以下是我的線性布局中的代碼:

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

我不明白為什么會這樣。 有人可以幫我嗎?

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM