implementation 'com.zackratos.ultimatebarx:ultimatebarx:0.3.1'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.1'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.1'
//activity的布局
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:navGraph="@navigation/bug_navigation" />
</FrameLayout>
//navigation的布局
<navigation 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:id="@+id/mobile_navigation"
app:startDestination="@+id/bugFragment">
<fragment
android:id="@+id/bugFragment"
android:name="com.zackratos.ultimatebarx.sample.BugFragment"
tools:layout="@layout/fragment_image"/>
</navigation>
//Fragment代码
public class BugFragment extends Fragment {
public BugFragment() {
super(R.layout.fragment_image);
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
UltimateBarX.with(this)
.fitWindow(true)// 布局是否侵入状态栏(true 不侵入,false 侵入)
.color(Color.BLACK)
.applyStatusBar();
}
}
//fragment的布局
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ivYurisa"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"/>