在drawable文件夹中,我有white.xml
.......
在mainactivity.xml中我有textview
android:id="@+id/text1"
android:background="@drawable/white" />```
//secound textview same as above
**In mainActivity i want to get background Color and to compare them but its not working**
``` public void getColor(View view) {
Drawable color1 = findViewById(R.id.text1).getBackground();
Drawable color2 = findViewById(R.id.text2).getBackground();
if(color1 == color2)
enter code here
//its also not working with .equal function
}```
// how should i compare background color
1条答案
按热度按时间v7pvogib1#
如果您将直接色码用于只有以下单色的背景:
您可以通过以下方式获得整数颜色代码:
在您的情况下,您可以: