Instantly share code, notes, and snippets.

Embed
What would you like to do?
Android Gradient Toolbar and Statusbar
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient android:angle="0"
android:startColor="#FFF6B7"
android:endColor="#F6416C"/>
</shape>
RelativeLayout layout = (RelativeLayout) findViewById(R.id.rel);
GradientDrawable drawable = new GradientDrawable();
drawable.setColors(new int[] {
Color.parseColor("#FFF6B7"),
Color.parseColor("#F6416C")
});
drawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
drawable.setOrientation(GradientDrawable.Orientation.LEFT_RIGHT);
layout.setBackground(drawable);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//must be called before setContentView(...)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
}
setContentView(R.layout.activity_main);
//The rest of the code goes here
}
<RelativeLayout
android:id="@+id/rel"
android:background="@drawable/linear_gradient_drawable"
android:layout_width="match_parent"
android:layout_height="80dp">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_alignParentBottom="true"
app:title="Android Gradient Toolbar"
app:titleTextColor="#52565c">
</android.support.v7.widget.Toolbar>
</RelativeLayout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment