As part of a much more complex piece of functionality I've become stuck on the ability to show a circle becoming opaque at a certain point of the screen.
I've gone as far as to create a test project where my Animation code is as follows:
View mLongPressImage; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mLongPressImage = findViewById(R.id.onPressImage); findViewById(R.id.button).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startAnimation(v.getX(), v.getY()); } }); } private AlphaAnimation onPressAnimation; private void startAnimation(final float f, final float g) { Log.v("", "START"); mLongPressImage.setX(f); mLongPressImage.setY(g); onPressAnimation = new AlphaAnimation(0f, 1f); onPressAnimation.setDuration(1000); onPressAnimation.setFillAfter(true); onPressAnimation.setFillEnabled(true); mLongPressImage.startAnimation(onPressAnimation); } Logging show's the correct event's are happening.
View looks like so:
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="PRESS ME" /> <ImageView android:id="@+id/onPressImage" android:layout_width="200dp" android:layout_height="200dp" android:background="#000000" android:scaleType="fitXY" android:src="@drawable/shape_circle_onpress" /> </FrameLayout> Right now the Image simply appears at the coordinates after 1 second has passed.
Can anybody point out the hidden flaw in this extremely simple piece of functionality?