开发者

How to change title bar color without theme

开发者 https://www.devze.com 2023-03-17 22:01 出处:网络
How I can change background color of titlebar without using theme开发者_如何学JAVA. tnks in Android.Try with the following code

How I can change background color of titlebar without using theme开发者_如何学JAVA. tnks in Android.


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);
      }
    }


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


I think this other dicussion will be helpful to you:

Set title background color

0

精彩评论

暂无评论...
验证码 换一张
取 消