如何更改Material Chip View的边框颜色和关闭/删除按钮?

时间:2017-11-15 09:26:58

标签: android android-chips

我正在使用 Material Chip View 。无论如何,我有没有改变芯片边框颜色和删除/删除芯片按钮?

  

材料芯片视图 https://github.com/robertlevonyan/materialChipView

1 个答案:

答案 0 :(得分:0)

我推荐了你的lib。

您可以通过从库中替换其图像(名为' ic_close.png')轻松更改删除/删除按钮。

要添加边框,您需要更改abb a; int main(){ tipoelem *ptr = a->info; ptr->comp_lexico = 2; } 代码,

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>

它看起来像这样,

enter image description here

希望这可以帮助你!!