Create Gradient
into res\xml\table.xml
like:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:startColor="#C0C0C0"
android:endColor="#505050"
android:angle="90"/>
<corners android:radius="2px" />
</shape>
And set to your TableLayout
background
TableLayout table = (TableLayout)findViewById(R.id.tableLayout1);
table.setBackgroundDrawable(getResources().getDrawable(R.xml.table));
And Programmatically you can achieve like:
GradientDrawable gd = new GradientDrawable(
GradientDrawable.Orientation.TOP_BOTTOM,
new int[] {Color.parseColor("#C0C0C0"), Color.parseColor("#505050")});
gd.setGradientCenter(0.f, 1.f);
gd.setLevel(2);
table.setBackgroundDrawable(gd);