[英]How to change title bar color without theme
如何在不使用主題的情況下更改標題欄的背景顏色。 Android 中的 tnks。
嘗試使用以下代碼
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)));
我認為其他討論將對您有所幫助:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.