나는 재료 칩보기을 사용하고 있습니다. 칩 테두리 색상과 칩 제거/삭제 버튼을 변경하는 방법이 있습니까?Material Chip View의 테두리 색상 및 닫기/삭제 버튼을 변경하는 방법은 무엇입니까?
답변
나는 당신의 주어진 lib 디렉토리를 언급했다.
삭제/삭제 버튼을 라이브러리 ('ic_close.png')에서 대체하여 쉽게 변경할 수 있습니다. 당신의 색상을 변경해야
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();
}
그리고
과 같은 Chip.java
의 코드를 변경해야 테두리를 추가
<color name="colorChipCloseClicked">#F5F5F5</color>
<color name="colorChipCloseClicked">#D32F2F</color>
로는 다음과 같이 될 것입니다 ,
희망이 도움이됩니다!
그것이 가능합니까? 읽어 보지 않았습니까? –
@hibiki 당신은이 lib를 Android Studio 프로젝트의 모듈로 가져 왔습니까? – Dhruv
가져온 방법? 나는 gradle을 사용하여 –
지금까지 어떤 시도를하셨습니까? – pix
@pix 나는 그것의 라이브러리로 직접 변경하려고 시도했으나 ... 읽었습니다. 단지 .. 나는 안드로이드 네이티브 개발을 처음 접했습니다. 나는 도서관을 사용하는 가족이 아니며 이것은 나의 첫 번째 시도이다 –