android - 以编程方式将 strokeColor 设置为 CardView
问题描述
我正在尝试strokeColor
以编程方式设置,但它不起作用。这是我尝试过的
gold_card.strokeColor= Color.GREEN
查看strokeColor的官方方法,它需要一个参数
public void setStrokeColor(@ColorInt int strokeColor) {
this.cardViewHelper.setStrokeColor(strokeColor);
}
因此,在传递 Color int 参数时,它表示无法访问代码。下面的方法说无法访问的代码
gold_card.strokeColor(Color.GRAY)
那么如何设置strokeColor
为CardView
正确的方式呢?PS:是的,我正在使用MaterailCardView
解决方案
您需要定义gold_card
为MatericalCardView
,而不是CardView
。
MatrialCardView gold_card = findViewById(R.id.cold_card)
推荐阅读
- c# - 在计算器的方法之间传递变量时出现 CS7036 错误(来自我在互联网上找到的代码测试)
- javascript - 如何使用 SAPUI5 将数组加载到片段内的下拉列表中?
- javascript - chrome.tabs.highlight 突然不起作用
- angular - 如何在nativescript中使用MapView在html中使用数据
- java - 找到所有可能的大数组对的 AND-Product 的最佳方法是什么?
- python - 如何使用日期时间索引加入两个数据帧,同时只保留同一时期的数据?
- node.js - 带有 DwD 的 GSuite 服务帐户未经授权访问用户的 Gmail 帐户
- r - 如何使用 KNN 预测 R 中的某些内容?
- magento - 如何根据 ProductRepository::getList() 返回的集合在 catalog_category_view 页面上加载类别
- java - 将 HashMap 逐个保存到文件