我需要在SplashScreen中隐藏一个BottomNavigationView
,它是一个Fragment
。我正在实现导航组件,因此我试图将其限制为仅使用一个Activity
,并且我认为这是我遇到的问题的一部分。
在mi FragmentSplashScreen
中,我有:
public class FragmentSplashScreen extends Fragment {
private BottomNavigationView bottomNavigationView;
public View onCreateView(LayoutInflater inflater, final ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_splash_screen, container, false);
bottomNavigationView = v.findViewById(R.id.navview_bottom);
bottomNavigationView.setVisibility(View.GONE);
return v;
}
}
[我认为我在处理片段及其底层Activity
时误解了一些东西>
(对不起我的英语不好)
编辑
添加ActivityMain
的布局
<androidx.constraintlayout.widget.ConstraintLayout
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"
tools:context=".viewPackage.ActivityMain">
<fragment
android:id="@+id/nav_host_fragment_login"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
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"
app:layout_constraintVertical_bias="0.0"
app:navGraph="@navigation/nav_graph" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/navview_bottom"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
app:itemIconTint="@color/colorAccent"
app:itemTextColor="@color/colorAccent"
app:layout_constraintBottom_toBottomOf="@+id/nav_host_fragment_login"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0"
app:menu="@menu/bottom_nav">
</com.google.android.material.bottomnavigation.BottomNavigationView>
</androidx.constraintlayout.widget.ConstraintLayout>
我需要在SplashScreen中将BottomNavigationView隐藏为片段。我正在实现导航组件,因此我试图将其限制为仅使用一个Activity,并且我认为这是...
问题是您正在尝试更新navview_bottom
,这是另一个View
。