Question

I have TableLayout in my project which contains 6 TableRow layouts. Each TableRow layout has 7 TextViews in it. I want to set a background image to this TableLayout which is currently displaying 42 TextViews. I also had set some background color to each TextView. I tried this

mDateSelectionBar.setBackgroundResource(resid);

But it is not showing up my Image. However, If I do this for my 42 TextViews..

TextView.setBackgroundResource(0);

Then my Image is visible. But I want to display TableLayout background Image as well as background color of each TextView. How can I do this? Please Help! Thanks :D

Was it helpful?

Solution

The issue is that the background of the individual cells in a table layout is drawn over the overall layout background. If you remove the background of the cell, then the overall background is visible. If you need to display the background of the table as well as some colouring of the cells, consider setting the alpha channel of the cell background colour to less than 100%, e.g. 0.8 or something.

When you set the colour for your cells, use #ARGB syntax, e.g.

setBackgroundColour(Color.argb(192, 255, 0, 0));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top