Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
105 views
in Technique[技术] by (71.8m points)

android - Chip margin issue when I set isCloseIconVisible to false

I am creating Chips dynamically and everything is working fine but when I set isCloseIconVisible and add the chip to ChipGroup then there is some kind of empty space(like margin not padding) at start of chip.

How can I resolve that? Any help will be appreciated

This is how I am creating Chip

fun createChip(context: Context, text: String, closeIconVisible: Boolean = true): Chip {
    val chip = Chip(context)
    chip.text = text
    chip.setChipDrawable(ChipDrawable.createFromAttributes(context, null, 0, 
              R.style.Widget_MaterialComponents_Chip_Entry))
    chip.setChipBackgroundColorResource(android.R.color.transparent)
    chip.isCheckedIconVisible = false
    chip.setTextColor(context.getColor((R.color.theme_primary)))
    chip.setCloseIconTintResource(R.color.theme_primary)
    chip.setBackgroundResource(R.drawable.style_rectangle_border)
    chip.setChipStrokeColorResource(R.color.theme_primary)
    chip.chipStrokeWidth = ProductConstants.CHIP_STROKE_WIDTH
    chip.isCloseIconVisible = closeIconVisible
    chip.isEnabled = closeIconVisible
    return chip
}
question from:https://stackoverflow.com/questions/65918878/chip-margin-issue-when-i-set-iscloseiconvisible-to-false

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...