实现状态栏一体化

来源:互联网 发布:个人备案需要域名吗 编辑:程序博客网 时间:2024/05/02 13:49
public void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentView(R.layout.activity_main);    initWindow();}/** * 初始化组件 */private SystemBarTintManager tintManager;@TargetApi(19)private void initWindow() {    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);        tintManager = new SystemBarTintManager(this);        tintManager.setStatusBarTintColor(ContextCompat.getColor(this, R.color.primary));        tintManager.setStatusBarTintEnabled(true);        tintManager.setNavigationBarTintEnabled(true);    }}

<resources>    <!-- Base application theme. -->    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">        <!-- Customize your theme here. -->        <item name="android:fitsSystemWindows">true</item>    </style></resources>

0 0