![](/img/trans.png)
[英]Android Chip_How to make chip background color transparent programmatically?
[英]How to make chip background transparent in android?
我正在使用動作芯片,例如:
<com.google.android.material.chip.Chip
android:id="@+id/copyLinkChip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/copy_link"
app:chipIcon="@drawable/content_copy_background"
app:chipIconTint="?attr/primaryText"
android:textColor="?attr/primaryText"
app:chipStrokeWidth="0.5dp"
/>
我想讓它的背景完全透明怎么做?
嘗試這個
chip.setChipBackgroundColor(getResources().getColorStateList(android.R.color.transparent));
您可以通過setChipBackgroundColorResource API 以編程方式設置它:
copyLinkChip.setChipBackgroundColorResource(android.R.color.transparent)
或通過 XML
app:chipBackgroundColor="@android:color/transparent"
您可以在 XML 中使用屬性app:chipBackgroundColor
chipBackgroundColor
app:chipSurfaceColor="@android:color/transparent"
app:chipBackgroundColor="@android:color/transparent"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.