I have this following code and everything work as follow. except that the remove view is not working. what is wrong with my code? does remove view do not work inside animation?
on my oncreate
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_edit_profile);
mWinManager = (WindowManager) ManageProfileActivity.this
.getSystemService(Context.WINDOW_SERVICE);
final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
| WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, PixelFormat.TRANSLUCENT);
params.width = WindowManager.LayoutParams.MATCH_PARENT;
params.height = WindowManager.LayoutParams.MATCH_PARENT;
mParentView = new FrameLayout(ManageProfileActivity.this);
mParentViewlayout = new FrameLayout.LayoutParams(100, 100);
mWinManager.addView(mParentView, params);
on my gridView Item Click
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
ImageView original = (ImageView) view.findViewById(R.id.avatar_imageview);
final ImageView img = new ImageView(ManageProfileActivity.this);
img.setVisibility(View.VISIBLE);
img.setImageDrawable(original.getDrawable());
mParentView.addView(img, mParentViewlayout);
int[] img_coordinates = new int[2];
mGroupAvatarImageView.getLocationOnScreen(img_coordinates);
float mX = (float) ((img_coordinates[0]));
float mY = (float) ((img_coordinates[1]));
TranslateAnimation anim = new TranslateAnimation(x, mX, y, mY);
anim.setDuration(300);
anim.setAnimationListener(new TranslateAnimation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
//THIS IS NOT WORKING
mParentView.removeView(img);
mParentView.invalidate();
}
});
img.startAnimation(anim);