1.android 改变状态栏的颜色,2 设置透明渐变式的样式!,设置状态栏为透明的渐变的

 
第一种是设置特定颜色的状态栏,不是渐变透明的在清单文件里面的apilication使用 
 
<application
    android:name=".TntApplication"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimaryDark</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="actionMenuTextColor">@color/colorFFFFFF</item>
    <item name="android:windowTranslucentNavigation" tools:ignore="NewApi">false</item>

</style>

1.colorPrimary 应用的主要色调,actionBar默认使用该颜色,Toolbar导航栏的底色

2.colorPrimaryDark 应用的主要暗色调,statusBarColor默认使用该颜色

3.colorAccent  为EditText,CheckBox,RadioButton,SwitchCompat等一般控件的选中效果默认采用该颜色,比如光标

4.actionMenuTextColor 菜单栏组件的字体颜色

第二种,设置渐变透明的状态栏,底部有虚拟按钮时会自动顶起,

getWindow().requestFeature(Window.FEATURE_NO_TITLE);
Window window = getWindow();
//4.4版本及以上
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
            WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    // Translucent navigation bar
    window.setFlags(
            WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
            WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
}
//5.0版本及以上
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
            | WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    window.setStatusBarColor(Color.TRANSPARENT);

放在baseActivity就可以了



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值