I have the following code and everything works as follows. except that the deletion view does not work. what is wrong with my code? Does the viewing not work inside the animation?
in 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);
in the gridView element 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) {
mParentView.removeView(img);
mParentView.invalidate();
}
});
img.startAnimation(anim);
source
share