我正在使用Material Chip View。无论如何我可以更改芯片边框颜色和删除/删除芯片按钮吗?
问问题
1810 次
1 回答
0
我提到了你给定的库。
您可以通过从库中替换其图像(名为“ic_close.png”)轻松更改删除/删除按钮。
并且要添加边框,您需要更改Chip.java
类似的代码,
private void initTypedArray(AttributeSet attrs) {
TypedArray ta = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.Chip, 0, 0);
chipText = ta.getString(R.styleable.Chip_mcv_chipText);
hasIcon = ta.getBoolean(R.styleable.Chip_mcv_hasIcon, false);
chipIcon = ta.getDrawable(R.styleable.Chip_mcv_chipIcon);
closable = ta.getBoolean(R.styleable.Chip_mcv_closable, false);
selectable = ta.getBoolean(R.styleable.Chip_mcv_selectable, false);
backgroundColor = ta.getColor(R.styleable.Chip_mcv_backgroundColor, ContextCompat.getColor(getContext(), R.color.colorChipBackground));
selectedBackgroundColor = ta.getColor(R.styleable.Chip_mcv_selectedBackgroundColor, ContextCompat.getColor(getContext(), R.color.colorChipBackgroundClicked));
textColor = ta.getColor(R.styleable.Chip_mcv_textColor, ContextCompat.getColor(getContext(), R.color.colorChipText));
selectedTextColor = ta.getColor(R.styleable.Chip_mcv_selectedTextColor, ContextCompat.getColor(getContext(), R.color.colorChipTextClicked));
closeColor = ta.getColor(R.styleable.Chip_mcv_closeColor, ContextCompat.getColor(getContext(), R.color.colorChipCloseInactive));
selectedCloseColor = ta.getColor(R.styleable.Chip_mcv_selectedCloseColor, ContextCompat.getColor(getContext(), R.color.colorChipCloseClicked));
cornerRadius = (int) ta.getDimension(R.styleable.Chip_mcv_cornerRadius, getResources().getDimension(R.dimen.chip_height) / 2);
strokeSize = (int) ta.getDimension(R.styleable.Chip_mcv_strokeSize, 2);
strokeColor = ta.getColor(R.styleable.Chip_mcv_strokeColor, ContextCompat.getColor(getContext(), R.color.colorChipCloseClicked));
iconText = ta.getString(R.styleable.Chip_mcv_iconText);
iconTextColor = ta.getColor(R.styleable.Chip_mcv_iconTextColor, ContextCompat.getColor(getContext(), R.color.colorChipBackgroundClicked));
iconTextBackgroundColor = ta.getColor(R.styleable.Chip_mcv_iconTextColor, ContextCompat.getColor(getContext(), R.color.colorChipCloseClicked));
ta.recycle();
}
你需要改变颜色,<color name="colorChipCloseClicked">#F5F5F5</color>
到<color name="colorChipCloseClicked">#D32F2F</color>
它会是这样的,
希望这对你有帮助!!
于 2017-11-15T09:53:41.997 回答