Java BottomNavigationVIew:覆盖其他布局的故障

Java BottomNavigationVIew:覆盖其他布局的故障,java,android,Java,Android,我正在使用BottomNavigationView并将ListView添加到布局中。添加此列表视图后,上一个屏幕不会消失,此新屏幕将覆盖上一个屏幕。有人知道为什么会这样吗 import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import an

我正在使用
BottomNavigationView
并将
ListView
添加到布局中。添加此
列表视图后,上一个屏幕不会消失,此新屏幕将覆盖上一个屏幕。有人知道为什么会这样吗

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import java.util.ArrayList;

public class favaoritesFragment extends Fragment {
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState){
        View view = inflater.inflate(R.layout.fragment_favorites,container,false);

        String[] line =getResources().getStringArray(R.array.JR_East);
        ListView listView = (ListView)view.findViewById(R.id.listview);
        ArrayAdapter<String>adapter = new ArrayAdapter<String>(getActivity(),android.R.layout.simple_list_item_1,line);
        listView.setAdapter(adapter);

        return view;
    }
}
    <ListView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/listview"/>
</RelativeLayout>
导入android.os.Bundle;
导入android.view.LayoutInflater;
导入android.view.view;
导入android.view.ViewGroup;
导入android.widget.ArrayAdapter;
导入android.widget.ListView;
导入androidx.annotation.Nullable;
导入androidx.fragment.app.fragment;
导入java.util.ArrayList;
公共类favaoritesFragment扩展了片段{
@凌驾
CreateView上的公共视图(布局、充气机、视图组容器、捆绑包保存状态){
视图=充气机。充气(R.layout.fragment\u收藏夹,容器,false);
String[]line=getResources().getStringArray(R.array.JR_East);
ListView=(ListView)view.findViewById(R.id.ListView);
ArrayAdapteradapter=新的ArrayAdapter(getActivity(),android.R.layout.simple_list_item_1,第行);
setAdapter(适配器);
返回视图;
}
}

    <ListView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/listview"/>
</RelativeLayout>

在所有片段的父视图中添加背景

    <ListView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/listview"/>
</RelativeLayout>
android:background="@android:color/white"

显示布局xml以及如何执行屏幕事务。也许这也和风格有关。谢谢你的回复。添加android:background=“@android:color/white”故障已修复。投票+将更加感激。