I have an ImageView. After loading the bitmap into onPostExecute, I call setImageDrawable to populate the imageView (I use CircleImageView) with the image. But TransitionDrawable shows only the 1st image and the transaction is not performed. How should I do it? Thanks in advance.
private void setImageDrawable(ImageView imageView, Bitmap bitmap) {
if (mFadeInBitmap) {
BitmapDrawable drawable = null, placeholder = null;
if (bitmap != null) {
drawable = new BitmapDrawable(mResources, bitmap);
placeholder = new BitmapDrawable(mResources, mPlaceHolderBitmap);
}
final TransitionDrawable td =
new TransitionDrawable(new Drawable[] {
placeholder,
drawable,
});
imageView.setImageDrawable(td);
td.startTransition(200);
} else {
imageView.setImageBitmap(bitmap);
}
}
UPDATE: I found a solution why this does not work for me in the CircleImageView documentation: "Using TransitionDrawable with CircleImageView does not work properly and leads to corrupted images." ( https://github.com/hdodenhof/CircleImageView ).
So can anyone suggest to me how I can get a circle image fading into the animation?
2:
, , , , , . .
fade_out.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true">
<alpha
android:fromAlpha="1.0"
android:toAlpha="0.0"
android:duration="100"
android:interpolator="@android:anim/accelerate_interpolator"
/>
</set>
fade_in.xml , , Alfa Alfa. , :
Animation anim = AnimationUtils.loadAnimation(mContext, R.anim.fade_out);
imageView.startAnimation(anim);
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
imageView.setImageBitmap(value);
Animation anim = AnimationUtils.loadAnimation(mContext, R.anim.fade_in);
imageView.startAnimation(anim);
}
}, 100);
, .