0
그래야 제대로 작동하는지 알 수 없습니다. 보기의 배경에 사용 된 드로어 블이 다른보기와 공유되는 인스턴스 인 경우 개인의 색을 변경하는 방법은 무엇입니까? 로 R.drawable.circle_shape을 가진드로어 블 싱글 톤이
:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<corners android:radius="10dip"/>
<solid android:color="#cccccc"/>
</shape>
한 조각
<ImageView
android:id="@+id/circle_1”
android:layout_width="22dp"
android:layout_height="22dp"
android:gravity="center"
android:layout_gravity="center"
android:background="@drawable/circle_shape"
android:shadowRadius="10.0"
/>
<ImageView
android:id="@+id/circle_2”
android:layout_width="22dp"
android:layout_height="22dp"
android:gravity="center"
android:layout_gravity="center"
android:background="@drawable/circle_shape"
android:shadowRadius="10.0"
/>
다른 사용은 다른 조각의 목록 항목의 템플릿을위한 두 개의 인스턴스로 사용
<ImageView
android:id="@+id/listItem_image”
android:layout_width="22dp"
android:layout_height="22dp"
android:gravity="center"
android:layout_gravity="center"
android:background="@drawable/circle_shape"
android:shadowRadius="10.0"
/>
인스턴스 c1의 원색을 변경할 때 c2 및 listItem_image chan을 발견했습니다. ges color 너무.
View c1 = (View) findViewById(R.id. circle_1);
c1.setBackgroundResource(R.drawable.circle_shape); // with or without this it will still affect the other ImageView which also uses R.drawable.circle_shape as background
((GradientDrawable) c1.getBackground()).setColor(intColor);
((GradientDrawable) c1.getBackground()).setStroke(0, Color.TRANSPARENT);
cool! Malcolm에게 감사드립니다. – lannyf