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>
I give a small animation, transition, to the imageView. After finishing the animation, imageView's background should be changed with a selector drawable inside a handler. However, for some reasons, its background is not applied, but when I click the imageView, it is applied. I have no idea on what's going on inside the handler. Any advice for this case?
This is how it looks like when the transition finished
But as you see this, I want to make it have the border around it. I don't understand why its background is not applied in the handler