【问题标题】:Change programmatically background color the entire column in TableLayout以编程方式更改 TableLayout 中整个列的背景颜色
【发布时间】:2016-01-25 20:54:53
【问题描述】:

是否有可能以编程方式更改 TableLayout 中整个列的背景颜色?

看这个:http://imgur.com/FgjaeOJ

【问题讨论】:

  • 获取所有列的循环并单独更改每列的颜色
  • 在提问之前,请确保您已阅读并理解 API 文档。搜索也很有帮助。这样的问题已经被回答了一百万次了。
  • 是的,伙计们,但我想到了其他事情,看看这个:imgur.com/FgjaeOJ

标签: java android tablelayout


【解决方案1】:

像这样试试。

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

【讨论】:

    【解决方案2】:

    这两种方法都可以;


    tr.setBackgroundResource(R.color.red);
    

    checkout this stack explaination

    【讨论】:

    • 如果您使用两个 TableLayout,则必须设置逻辑,即何时更改颜色,但您可以按照我的回答 @Peter 中所写的上述语法更改颜色
    【解决方案3】:
    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));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-28
      • 1970-01-01
      • 2019-04-22
      相关资源
      最近更新 更多