English 中文(简体)
如何在安的安伯正确藏匿海底Appbar
原标题:How to correctly hide BottomAppbar in Android

I m trying to hide my bottom appBar in other fragments, so it cannot be visible. I tried to do it in this way

public void hideBottomMenu() {
    appBarLayout.setVisibility(View.GONE);
    bottomNavigationView.setVisibility(View.GONE);
    fabAdd.hide();
}

以下是一些屏幕:

“从屏幕上筛选”/</a

“从布局检查员处抽取的素”,</a

但是,我认为,这并不正确,而是看不见的,但当我提出某种观点时,这种看法出现在屏幕的底层(即底线的可见度)。

在这方面,我的主要活动是:

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <RelativeLayout
        android:id="@+id/fragment_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="55dp"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <com.google.android.material.appbar.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/white"
            app:layout_scrollFlags="scroll|enterAlways"
            app:menu="@menu/top_menu"
            app:title="Реєстр ТТН" />

        <FrameLayout
            android:id="@+id/flInternetAbsent"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#E36363"
            android:padding="2dp"
            android:visibility="gone">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:letterSpacing="0.05"
                android:text="Відсутній інтернет"
                android:textColor="@color/white" />
        </FrameLayout>

    </com.google.android.material.appbar.AppBarLayout>


    <com.google.android.material.bottomappbar.BottomAppBar
        android:id="@+id/bottomAppBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        app:fabCradleMargin="10dp"
        app:fabCradleRoundedCornerRadius="20dp">

        <com.google.android.material.bottomnavigation.BottomNavigationView
            android:id="@+id/bottomNavigationView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginEnd="16dp"
            android:background="@android:color/transparent"
            app:itemIconTint="@color/bottom_nav_color"
            app:itemTextColor="@color/bottom_nav_color"
            app:menu="@menu/bottom_nav_menu" />

    </com.google.android.material.bottomappbar.BottomAppBar>

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/add"
        app:backgroundTint="@color/primary_color"
        app:layout_anchor="@id/bottomAppBar" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>
问题回答

这方面有许多办法(我不喜欢其中任何一种)。 我倾向于在碎块内设置底线,因为在大多数碎片中,我没有使用。 因此,一小块碎块是罚款的。

www.un.org/Depts/DGACM/index_spanish.htm 第二种方式是。 指出在这一秩序中树立可见度很重要(我通过尝试和错误在无希望办法之后实现这一点): 首先隐藏着FAB(使用fab.hide(”),但这种说法看不见(我这样做只是要确保它不会再出现。 使用fab.setVisibility(View.GONE),然后使用《无形的巴塞尔公约》(使用bottomAppBar.setVisibility(View.GONE)。 内容提要

    public void hideBottomMenu() {
        fabAdd.hide();
        fabAdd.setVisibility(View.GONE);
        appBarLayout.setVisibility(View.GONE);
        //bottomNavigationView.setVisibility(View.GONE); do not use this. it is a child of bottombar.
    }

For showing these components define:

    public void showBottomMenu() {
        appBarLayout.setVisibility(View.VISIBLE);
        appBarLayout.performShow();
        //fabAdd.setVisibility(View.VISIBLE); // I am not sure about this.
        fabAdd.show();
        //bottomNavigationView.setVisibility(View.GONE); do not use this. it is a child of bottombar.
    }

然后,在<条码>上,你想要掩盖底部的碎片 律师

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    ((MainActivity) requireActivity()).hideBottomMenu();
    }




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签