Создать запрещенное представление в android - PullRequest
0 голосов
/ 29 января 2020

Я хочу создать запрещенное представление, и вот как далеко я продвинулся: Перед нажатием кнопки, которая показывает представление

После нажатия кнопки, которая показывает view

Основная цель для этого состоит в том, что я хочу сделать мое представление vani sh, когда я нажимаю на любую другую часть экрана. Я попытался создать макет, который состоит из двух частей, но похоже, что он тоже не работает. Вот мой нынешний xml:

<androidx.coordinatorlayout.widget.CoordinatorLayout 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"
    android:background="#E91E63"
    tools:context=".MainActivity">


    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>


    <Button
        android:id="@+id/button"
        android:layout_width="401dp"
        android:layout_height="wrap_content"
        android:layout_gravity="top|end"
        android:text="Button" />

    <LinearLayout
        android:id="@+id/bottom_sheet"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/darker_gray"
        android:orientation="vertical"
        app:behavior_hideable="false"
        app:behavior_peekHeight="80dp"
        app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="80dp"
            android:background="@color/colorAccent"
            android:gravity="center"
            android:text="up"
            android:textColor="@android:color/white"
            android:textColorHighlight="#FFF"
            android:textColorLink="#fff" />

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/productList"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />


    </LinearLayout>

    <View
        android:id="@+id/view"
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:background="#8BC34A"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:theme="@style/Theme.AppCompat.Dialog.Alert"
        app:layout_constraintVertical_bias="0.0" />


    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottom_navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:background="@color/colorPrimary"
        app:itemIconTint="#fff"
        app:itemTextColor="#fff"
        app:labelVisibilityMode="labeled"
        app:menu="@menu/bottom_menu" />


</androidx.coordinatorlayout.widget.CoordinatorLayout>
...