EditTag
EditTag copied to clipboard
How to change background colors of the tag programatically?
Hi,
First of all I would like to say thanks for this awesome library. It is really helpful.
Now I am trying to change the background color of the tags programatically but I can't find anything that does that. It seems the layout we set in the EditTag field only changes the background color. Below is the code that I tried to change the background color but it only changes the color of the first tag only,
editTagView.findViewById(R.id.txt_lable).setBackgroundColor(Color.BLACK);
How can I change the background color for all the tags?
I'm sorry, there is currently no way to dynamically change the background color of the tag, in order to customize the tag attribute, it can only be specified at initialization.
@qiugang I added the whole library as a module in my project and made my own customisations to change the background color of the tag programmatically.
`txtEditTag.setTagColor(Theme.SECONDARYCOLOR);
In the EditTag Class public void setTagColor(String tagColor) { this.tagColor = tagColor; }
public boolean addTag(String tagContent, String colorString) { if (TextUtils.isEmpty(tagContent)) { // do nothing, or you can tip "can't add empty tag" return false; } else { if (tagAddCallBack == null || (tagAddCallBack != null && tagAddCallBack.onTagAdd(tagContent))) { TextView tagTextView = createTag(flowLayout, tagContent); // if (defaultTagBg == null) { // defaultTagBg = tagTextView.getBackground(); // } tagTextView.setBackgroundColor(Color.parseColor(colorString)); tagTextView.setOnClickListener(EditTag.this); if (isEditableStatus) { flowLayout.addView(tagTextView, flowLayout.getChildCount() - 1); } else { flowLayout.addView(tagTextView); }
tagValueList.add(tagContent);
// reset action status
editText.getText().clear();
editText.performClick();
isDelAction = false;
return true;
}
}
return false;
}
`