Android examples for User Interface:View Background
set View Gradient Background
//package com.java2s; import android.graphics.Color; import android.graphics.drawable.GradientDrawable; import android.view.View; public class Main { public static void setGradientBackground(View view, int[] colors) { int[] color = new int[] { Color.parseColor("#8FC550"), Color.WHITE }; if (colors != null && colors.length > 2) { color = colors;// w w w.j av a 2 s .co m } GradientDrawable gd = new GradientDrawable( GradientDrawable.Orientation.BOTTOM_TOP, color); gd.setCornerRadius(0f); view.setBackgroundDrawable(gd); } }