[英]change navigation bar color like canva app
I want design splash screen like canva app. 我想要设计像Canva应用程序的启动画面。 Like
喜欢
(This screenshot taken from android API version 26). (此屏幕截图取自android API版本26)。
I tried this code in Activity.java: 我在Activity.java中尝试了以下代码:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = getWindow();
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
}
}
And XML code is: XML代码是:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/gradient_splash_screen">
<FrameLayout
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_centerInParent="true"
android:background="@drawable/icon_splash_screen">
<TextView
android:id="@+id/tv_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/app_name"
android:textColor="#678ee4"
android:textSize="28sp" />
</FrameLayout>
</RelativeLayout>
I referred this question recently but its not enough to change navigation bar icon color to white. 我最近提到了这个问题,但不足以将导航栏图标的颜色更改为白色。
I see there is no action bar in the screenshot. 我看到屏幕截图中没有操作栏。
You can create a screen without an action bar and transparent status bar and transparent navigation bar. 您可以创建没有操作栏,透明状态栏和透明导航栏的屏幕。
Create styles like below. 创建如下样式。
<style name="AppTheme.NoActionBar" parent="AppTheme">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.NoActionBar.TranslucentStatus" parent="AppTheme.NoActionBar">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>
Apply the above AppTheme.NoActionBar.TranslucentStatus
to your activity in the manifest
将上述
AppTheme.NoActionBar.TranslucentStatus
应用于manifest
活动
The above method only works from lollipop (v21) 以上方法仅适用于棒棒糖(v21)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.