Skip to content

Instantly share code, notes, and snippets.

@billyriantono
Created May 18, 2015 08:21
Show Gist options
  • Save billyriantono/7cf05eee1a975e0e7315 to your computer and use it in GitHub Desktop.
Save billyriantono/7cf05eee1a975e0e7315 to your computer and use it in GitHub Desktop.
Change ActionToolbar Android to be transparent
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@android:color/transparent" />
</shape>
public static void transparentBackgroundToolbarsIcon(Toolbar toolbarView) {
for (int i = 0; i < toolbarView.getChildCount(); i++) {
final View v = toolbarView.getChildAt(i);
if (v != null && v instanceof TextView) {
TextView t = (TextView) v;
t.setBackgroundResource(R.drawable.background_transparent);
}
if (v instanceof ActionMenuView) {
v.setBackgroundResource(R.drawable.background_transparent);
}
}
toolbarView.setBackgroundResource(R.drawable.background_transparent);
toolbarView.invalidate();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment