BOTTOM NAVIGATION VIEW HIDES

时间:2017-09-18 17:46:45

标签: android fragment bottomnavigationview

我的应用有问题。我有一个带有3个不同片段的底部导航视图,虽然目前只有主要的东西。当我尝试从左边的两个片段中的一个片段移动到主片段时,即隐藏底部导航视图时,会出现问题。我附上了主要代码。

PD:我拥有25.3.1版本中的所有库(如果有用)。

感谢您的关注。

activity_main.xml中

    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/containerr"
android:layout_width="match_parent"
android:layout_height="match_parent">

<FrameLayout
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="bottom">

<android.support.design.widget.BottomNavigationView
    android:id="@+id/navigation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:background="#0f6b96"
    app:itemIconTint="@drawable/color_state_light"
    app:itemTextColor="@drawable/color_state_light"
    app:menu="@menu/menu_bottom_navigation_basic">

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

MainActivity.java

BottomNavigationView bottomNavigationView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    bottomNavigationView = (BottomNavigationView) findViewById(R.id.navigation);
    bottomNavigationView.setOnNavigationItemSelectedListener(onNavigationItemSelectedListener);
    FragmentManager fragmentManager = getSupportFragmentManager();
    FragmentTransaction transation = fragmentManager.beginTransaction();
    transation.replace(R.id.container, new Home()).commit();


}
private BottomNavigationView.OnNavigationItemSelectedListener onNavigationItemSelectedListener = new BottomNavigationView.OnNavigationItemSelectedListener() {
    @Override
    public boolean onNavigationItemSelected(@NonNull MenuItem item) {

        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction transation = fragmentManager.beginTransaction();


        switch (item.getItemId()){

            case R.id.home:
                transation.replace(R.id.container, new Home()).commit();
                return true;

            case R.id.ofertas:
                transation.replace(R.id.container, new Ofertas()).commit();
                return true;

            case R.id.contacto:
                transation.replace(R.id.container, new Contacto()).commit();
                return true;

        }


        return false;
    }
};

我也给你添加了两张图片。

Ofertas Fragment

Home Fragment

1 个答案:

答案 0 :(得分:0)

问题出在fitSystemWindow == true中,我遇到了类似的问题,删除后问题就消失了。