Well, it depends on the type of background.
If you are talking about a background as in a view(linearlayout, surfaceview, etc) wit ha color, you have to get the position the textview has on the screen, and set a color based on the background color at that point. But it depends on the type of color. A bitmap allows you to get a specific pixel:
bmp.getPixel(x, y);
And then you can determine the color based on that.
However, with a SurfaceView it becomes harder because there is no native method for that.
Further, a gradient-filled background makes it harder to get at a particular point. But if you use a view and have set the backgroundcolor, you can:
if (view.getBackground() == Color.RED){//View = the view with a background set using setBackground or android:background="@color or @drawable or whatever"
tv.setTextColor(Color.WHITE); //then you adjsut the textview color
}
Please be aware that the above example only works if the view has a background defined as android:background or setBackground and there is a color. When you use a bitmap, you can get the pixel and the color based on that pixel