[英]Setting Material chip Icon stroke/background color
so I'm trying to generate a button that looks like this 所以我试图生成一个看起来像这样的按钮
so far what I've achieved looks like this 到目前为止,我所取得的成就看起来像这样
This is the code I'm using 这是我正在使用的代码
chip.setChipStrokeColorResource(R.color.utilitiesColor)
chip.chipStrokeWidth = 2.0f
chip.setChipIconTintResource(R.color.utilitiesColor) //T
chip.setCloseIconTintResource(R.color.utilitiesColor) //T
chip.setTextColor(Color.parseColor("#115fff"))
chip.setTypeface(null, Typeface.BOLD)
chip.chipIcon = ContextCompat.getDrawable(this.context, R.drawable.ic_utilities)
The 2 lines i've commented with T are the ones I tried adding to achieve this icon background color but they don't seem to change anything, you may not see the icon in the picture but it's there its just white on white so you can't see without the stroke. 我用T注释过的2行是我尝试添加的行,以实现此图标的背景颜色,但它们似乎并没有改变任何内容,您可能看不到图片中的图标,但那里只是白色,因此您没有中风就看不到
Any help is appreciated. 任何帮助表示赞赏。
Please check this formate 请检查这个队友
<android.support.constraint.ConstraintLayout
android:layout_width="150dp"
android:layout_height="50dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:id="@+id/text1"
app:layout_constraintBottom_toBottomOf="parent"
android:background="@drawable/round_button">
<TextView
android:layout_width="150dp"
android:layout_height="50dp"
android:gravity="center"
android:text="Utilites (200)"
android:layout_marginEnd="10dp"
android:paddingLeft="5dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:textAlignment="viewEnd"
/>
</android.support.constraint.ConstraintLayout>
<ImageView
android:id="@+id/imageView"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginStart="120dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toEndOf="@id/text1"
app:srcCompat="@drawable/your_image" />
round.xml round.xml
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="10dp" />
<solid android:color="@android:color/white" />
<stroke
android:color="@android:color/holo_blue_dark"
android:width="2dp">
</stroke>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.