android - 按来源更改颜色 actionBar Material 设计

标签 android colors android-actionbar android-5.0-lollipop material-design

我想将 ActionBar 的颜色更改为“materials design”样式,但是方法 setbackgrounddrawable 将 ActionBar 的样式更改为“holo”。有谁知道“Android SDK L”是否有新方法?谢谢。

最佳答案

从代码中调用 getActionBar().setBackgroundDrawable()

我已经测试过了,一切正常。尝试我的代码(稍长但结果不错),我使用的是 Appcompat,但它在所有 API 中的工作方式相同:

private void colorizeAB(){
        Random random = new Random();
        int color = Color.rgb(random.nextInt(256), random.nextInt(256), random.nextInt(256));
        getSupportActionBar().setBackgroundDrawable(new ColorDrawable(color));
        new Handler().postDelayed(new Runnable() {

            @Override
            public void run() {
                colorizeAB();
            }
        }, 1000);
    }

关于android - 按来源更改颜色 actionBar Material 设计,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25380510/

相关文章:

android - fragment ViewPager NullPointer 问题

android - 带有 TextInputLayouts passwordToggleEnabled 的可见密码

colors - CKEditor:文本颜色和背景颜色可能有不同的调色板吗?

css - Angular 渐变与 CSS Webkit 渐变?

android - 主从流 Android 动画 API

android - 自定义 Android ActionBar

java - 为什么我的溢出下拉菜单位于操作栏顶部?

java - 从android中的linikedList中删除项目

java - 在 Android 中显示 httpGet 和响应之间的进度图像

Java/JavaFX 事件处理程序和 setFill() 问题