LinearLayout 可见性不 'GONE' 并且在 android 4.4.4 上也不显示

LinearLayout visibility not 'GONE' and also doesn't show on android 4.4.4

我使用 LinearLayout 作为 "skrim" 来覆盖按下浮动操作按钮后的布局,我将其设置为 alpha 设置为 .55 的颜色,并且它覆盖整个父级。在我的布局中,我将 LinearLayout 设置为 "gone" 然后在我的 kotlin 中,当 FAB 被感动了。

出于某种原因,LinearLayout 根本不会在 apk19 4.4.4 上显示,但它始终存在,这意味着您无法按迷你工厂的和。您可以按主 FAB,但别无他法。我有一个 setOnClickListener 用于 LinearLayout,所以我知道它被按下了,而不是迷你 FAB 的

这是“线性布局”:

<LinearLayout
        android:id="@+id/main_profile_overlay"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:alpha="0.55"
        android:foreground="@color/profile"
        android:orientation="vertical"
        android:visibility="gone" />

这里是 Kotlin 实用地改变 LinearLayout:

view.main_profile_overlay.visibility = View.GONE

view.main_profile_overlay.visibility = View.VISIBLE

为什么使用 GONE 布局不会消失,为什么不显示颜色和 alpha?

****编辑****

这是我的完整布局 我没有做任何修改 LinearLayout:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="220dp"
        android:fitsSystemWindows="true">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/profileUserCoverPhotoLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:collapsedTitleGravity="center"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:statusBarScrim="@color/profile"
            app:toolbarId="@+id/toolbar">

            <ImageView
                android:id="@+id/profileUserCoverPhoto"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:elevation="20dp"
                android:scaleType="centerCrop"
                android:src="@color/profile"
                app:layout_collapseMode="parallax" />
        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/editProfileCoverPhoto"
        app:fabSize="mini"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:clickable="true"
        android:layout_marginEnd="15dp"
        app:backgroundTint="@color/profile"
        app:layout_anchor="@+id/appbar"
        app:layout_anchorGravity="right|bottom"
        app:srcCompat="@drawable/ic_profile_edit_image" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/editPorofileUserPhoto"
        app:fabSize="mini"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:clickable="true"
        app:backgroundTint="@color/profile"
        app:layout_anchor="@+id/profileUserPhoto"
        app:layout_anchorGravity="bottom|right"
        app:srcCompat="@drawable/ic_profile_edit_image" />

    <android.support.v4.widget.NestedScrollView
        android:id="@+id/nestedScrollView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="56dp"
        android:layout_marginTop="-55dp"
        android:clipToPadding="true"
        android:fillViewport="true"
        android:overScrollMode="ifContentScrolls"
        app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior">

        <LinearLayout
            android:id="@+id/profilePersonalInfoChild"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:paddingEnd="10dp"
            android:paddingStart="10dp">

            <LinearLayout
                android:id="@+id/profilePersonalInfoChild2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:paddingBottom="25dp"
                android:paddingEnd="0dp"
                android:paddingStart="0dp">

                <ImageView
                    android:id="@+id/profileUserPhoto"
                    android:layout_width="150dp"
                    android:layout_height="150dp"
                    android:layout_marginStart="25dp"
                    android:foreground="@drawable/profile_image_border"
                    android:padding="0dp"
                    android:scaleType="centerCrop"
                    app:srcCompat="@android:color/transparent" />

                <LinearLayout
                    android:id="@+id/profilePersonalInfoChild3"
                    android:layout_width="match_parent"
                    android:layout_height="150dp"
                    android:orientation="vertical"
                    android:paddingBottom="25dp"
                    android:paddingEnd="0dp"
                    android:paddingStart="0dp">

                    <EditText
                        android:id="@+id/profileUsername"
                        android:layout_width="match_parent"
                        android:layout_height="100dp"
                        android:layout_marginBottom="0dp"
                        android:layout_marginEnd="1dp"
                        android:background="@null"
                        android:ems="10"
                        android:enabled="false"
                        android:focusable="false"
                        android:focusableInTouchMode="false"
                        android:gravity="bottom"
                        android:inputType="none"
                        android:orientation="horizontal"
                        android:padding="8dp"
                        android:singleLine="true"
                        android:text="@string/Username"
                        android:textColor="@color/black"
                        android:textSize="28sp" />

                    <EditText
                        android:id="@+id/profileMemberSince"
                        android:layout_width="match_parent"
                        android:layout_height="50dp"
                        android:background="@null"
                        android:ems="10"
                        android:enabled="false"
                        android:focusable="false"
                        android:focusableInTouchMode="false"
                        android:gravity="top"
                        android:inputType="textMultiLine"
                        android:paddingStart="10dp"
                        android:text="Member since September, 2018"
                        android:textColor="@color/black"
                        android:textSize="12sp"
                        tools:text="Member since September, 2018" />

                </LinearLayout>

            </LinearLayout>

            <TextView
                android:id="@+id/profileAboutMeLabel"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@null"
                android:enabled="false"
                android:focusable="false"
                android:focusableInTouchMode="false"
                android:inputType="none"
                android:labelFor="@+id/profileAboutMe"
                android:text="@string/aboutMe"
                android:textColor="@color/profile"
                android:textSize="18sp" />

            <TextView
                android:id="@+id/profileAboutMe"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@null"
                android:enabled="false"
                android:focusable="false"
                android:focusableInTouchMode="false"
                android:inputType="none"
                android:paddingBottom="20dp"
                android:text="My bio"
                android:textColor="@color/black" />

            <TextView
                android:id="@+id/profileCityLabel"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@null"
                android:enabled="false"
                android:focusable="false"
                android:focusableInTouchMode="false"
                android:inputType="none"
                android:labelFor="@+id/profileCity"
                android:text="@string/city"
                android:textAllCaps="false"
                android:textColor="@color/profile"
                android:textSize="18sp" />

            <TextView
                android:id="@+id/profileCity"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@null"
                android:enabled="false"
                android:focusable="false"
                android:focusableInTouchMode="false"
                android:inputType="none"
                android:paddingBottom="20dp"
                android:text="My city"
                android:textColor="@color/black" />

            <TextView
                android:id="@+id/profileAgeLabel"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@null"
                android:enabled="false"
                android:focusable="false"
                android:focusableInTouchMode="false"
                android:inputType="none"
                android:text="@string/age"
                android:textColor="@color/profile" />

            <TextView
                android:id="@+id/profileAge"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@null"
                android:enabled="false"
                android:focusable="false"
                android:focusableInTouchMode="false"
                android:inputType="none"
                android:paddingBottom="20dp"
                android:text="My age"
                android:textColor="@color/black"
                android:textSize="18sp" />

            <TextView
                android:id="@+id/profileOccupationLabel"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@null"
                android:enabled="false"
                android:focusable="false"
                android:focusableInTouchMode="false"
                android:inputType="none"
                android:labelFor="@+id/profileOccupation"
                android:text="@string/occupation"
                android:textColor="@color/profile"
                android:textSize="18sp" />

            <TextView
                android:id="@+id/profileOccupation"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@null"
                android:enabled="false"
                android:focusable="false"
                android:focusableInTouchMode="false"
                android:inputType="none"
                android:paddingBottom="20dp"
                android:text="My occupation"
                android:textColor="@color/black" />

            <TextView
                android:id="@+id/profileInterestsLabel"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@null"
                android:enabled="false"
                android:focusable="false"
                android:focusableInTouchMode="false"
                android:inputType="none"
                android:labelFor="@+id/profileInterests"
                android:text="@string/interests"
                android:textColor="@color/profile"
                android:textSize="18sp" />

            <TextView
                android:id="@+id/profileInterests"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@null"
                android:enabled="false"
                android:focusable="false"
                android:focusableInTouchMode="false"
                android:inputType="none"
                android:paddingBottom="20dp"
                android:text="My interests"
                android:textColor="@color/black" />
        </LinearLayout>

    </android.support.v4.widget.NestedScrollView>

    <LinearLayout
        android:id="@+id/main_profile_overlay"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:alpha="0.55"
        android:foreground="@color/profile"
        android:orientation="vertical"
        android:visibility="gone" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab_profile_open"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:src="@drawable/ic_profile_menu"
        android:layout_gravity="bottom|end"
        android:layout_marginEnd="20dp"
        android:layout_marginBottom="60dp"
        android:clickable="true"
        app:backgroundTint="@color/profile" />
    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab_profile_close"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:visibility="gone"
        app:srcCompat="@drawable/ic_close"
        android:layout_gravity="bottom|end"
        android:layout_marginEnd="20dp"
        android:layout_marginBottom="60dp"
        android:clickable="true"
        app:backgroundTint="@color/profile" />
    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab_profile_edit"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:src="@drawable/ic_profile_edit"
        android:layout_gravity="bottom|end"
        android:layout_marginBottom="82dp"
        android:layout_marginEnd="102dp"
        app:backgroundTint="@color/white"
        app:fabSize="mini"
        android:visibility="gone"
        android:clickable="true" />
    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab_profile_photo_edit"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        app:srcCompat="@drawable/ic_chatter_new_photo"
        android:layout_gravity="bottom|end"
        android:layout_marginBottom="142dp"
        android:layout_marginEnd="92dp"
        app:backgroundTint="@color/white"
        app:fabSize="mini"
        android:visibility="gone"
        android:clickable="true" />
    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab_profile_search"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        app:srcCompat="@drawable/ic_groups_search"
        android:layout_gravity="bottom|end"
        android:layout_marginBottom="154dp"
        android:layout_marginEnd="30dp"
        app:backgroundTint="@color/white"
        app:fabSize="mini"
        android:visibility="gone"
        android:clickable="true" />

    <ProgressBar
        android:id="@+id/profileProgressBar"
        style="?android:attr/progressBarStyle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:fitsSystemWindows="true"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</android.support.design.widget.CoordinatorLayout>

尝试设置背景色而不是前景色,并使布局高度与父级匹配

       <LinearLayout
          android:id="@+id/main_profile_overlay"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:alpha="0.55"
          android:background="@color/profile"
          android:orientation="vertical"
          android:visibility="gone" />