How to change title bar color without theme

寵の児 提交于 2020-01-03 15:21:15

问题


How I can change background color of titlebar without using theme. tnks in Android.


回答1:


Try with the following code

View titleView = getWindow().findViewById(android.R.id.titlebar);
    if (titleView != null) {
      ViewParent parent = titleView.getParent();
      if (parent != null && (parent instanceof View)) {
        View parentView = (View)parent;
        parentView.setBackgroundColor(Color.RED);
      }
    }



回答2:


ActionBar bar = getActionBar(); bar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.material_blue_gray1)));




回答3:


I think this other dicussion will be helpful to you:

Set title background color



来源:https://stackoverflow.com/questions/6582508/how-to-change-title-bar-color-without-theme

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!