2016-01-25 72 views
0

是否有可能以編程方式更改TableLayout中的整個列的背景色?以編程方式更改TableLayout中的整個列的背景顏色

看看這個:http://imgur.com/FgjaeOJ

+0

得到一個循環對所有列和更改每列的顏色分別 – user0946076422

+1

請確保您已經閱讀並提問之前瞭解的API文檔。另外一個搜索是非常有幫助的。這樣的問題已經回答了一百萬次。 –

+0

是的,但我想其他的東西,看看這個:http://imgur.com/FgjaeOJ – Peter

回答

1

嘗試這樣的。

TableRow tableRow = (TableRow) findViewById(rowID); 
        tableRow .setBackgroundColor(Color.BLACK); 
+0

看這個:http://imgur.com/FgjaeOJ – Peter

0

你可以這樣做;


tr.setBackgroundResource(R.color.red); 

checkout this stack explaination

+0

看這個:http://imgur.com/FgjaeOJ – Peter

+0

你的問題解決了嗎? @Peter –

+0

我使用了兩個TableLayout ... – Peter

0
TableLayout tableLayout = (TableLayout)findViewById(R.id.table_layout_sample); 
TableRow tableRow = (TableRow)tableLayout.findViewById(R.id.table_row); 
tableRow.setBackgroundColor(getResources().getColor(android.R.color.holo_orange_light)); 
+0

看看這個:http:// imgur.com/FgjaeOJ – Peter

相關問題