MainActivity.java
transition = new TransitionDrawable(new Drawable[]{
new ColorDrawable(Color.TRANSPARENT),
new BitmapDrawable(getResources(), BitmapFactory.decodeResource(getResources(), R.drawable.face1))
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
imageView.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.default_image, null));
}
imageView.setImageDrawable(transition);
transition.startTransition(3000);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
imageView.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.iv1_selector, null));
Log.d("LOG", "CALLED");
}
}
}, 3000);
iv1_selector.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:enterFadeDuration="@android:integer/config_shortAnimTime"
android:exitFadeDuration="@android:integer/config_mediumAnimTime">
<item android:drawable="@drawable/iv_focused_drawable" android:state_focused="true" />
<item android:drawable="@drawable/iv_not_focused_drawable" android:state_focused="false" />
</selector>
imageView に小さなアニメーション、トランジションを与えます。アニメーションが終了したら、imageView の背景をハンドラー内のドローアブル セレクターで変更する必要があります。ただし、何らかの理由で背景が適用されていませんが、imageViewをクリックすると適用されます。ハンドラーの内部で何が起こっているのかわかりません。この場合のアドバイスはありますか?
トランジションが終わるとこんな感じ
しかし、ご覧のとおり、境界線を付けたいと思います。背景がハンドラーに適用されない理由がわかりません