到目前为止,我可以更改ActionBar背景颜色,但我需要的是从ActionBar获取当前背景颜色。我怎么能这样做?
这是我的代码:
int newColor = Color.parseColor("#000000");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
Drawable colorDrawable = new ColorDrawable(newColor);
Drawable bottomDrawable = context.getResources().getDrawable(R.drawable.actionbar_bottom);
LayerDrawable ld = new LayerDrawable(new Drawable[] { colorDrawable, bottomDrawable });
((Activity) context).getActionBar().setBackgroundDrawable(ld);
}