我在我的約束佈局中有一個如下所示的圖標:icon。如何更改可繪製集的顏色爲android:background?
這是我爲這個圖像視圖佈局的xml:
<ImageView
android:id="@+id/vTotalPaidAvatar"
android:layout_width="40dp"
android:layout_height="40dp"
android:contentDescription="@null"
android:src="@drawable/ic_group_ic_total"
tools:src="@drawable/ic_group_ic_total"
app:layout_constraintLeft_toLeftOf="@+id/vSettleDebtsLayout"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
app:layout_constraintTop_toTopOf="@+id/vSettleDebtsLayout"
android:layout_marginTop="16dp"
android:background="@drawable/avatar_circle" />
正如你可以看到,圖標只是一個美元符號。我將該灰色圓圈設置爲背景。問題是我需要動態改變背景的顏色。美元符號需要保持白色。 我的問題是,有沒有辦法如何改變只有背景的顏色?
另一種解決方案是將該圓圈用作下一個imageview,然後更改該圖像視圖的顏色。但我認爲有可能是這個問題的一些「澄清溶液。
感謝提示:)
你解決了我的問題。謝謝 :) –