I show a layout with fade animation by manipulating its alpha levels with AlphaAnimation .
The current solution works fine on two of my devices that use Gingerbread, and one that uses Froyo. However, this does not work on an ice cream sandwich ?!
Here is my xml layout.
<LinearLayout android:id="@+id/photoOptionBar" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:alpha="0" android:background="@color/gpsBackground" android:orientation="horizontal"> <ImageButton android:id="@+id/displayShareBtn" style="@android:style/Widget.Holo.Button.Borderless.Small" android:background="@android:color/transparent" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" android:layout_gravity="center_vertical|center_horizontal" android:padding="20dp" android:src="@drawable/share" android:contentDescription="Share the picture"/> <ImageButton android:id="@+id/displayDiscardBtn" style="@android:style/Widget.Holo.Button.Borderless.Small" android:background="@android:color/transparent" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" android:layout_gravity="center_vertical|center_horizontal" android:padding="20dp" android:src="@drawable/contentdiscard" android:contentDescription="Discard Picture"/> </LinearLayout>
Here is my onCreate method to set the alpha value to 0 at boot, as it is done in xml, this does not work ...
AlphaAnimation alpha = new AlphaAnimation(0.0F, 0.0F); alpha.setDuration(0); // Make animation instant alpha.setFillAfter(true); // Tell it to persist after the animation ends // And then on your layout this._photoOptionsBar.startAnimation(alpha);
And then when I want to show it, I call the following.
public void showOptions() { AlphaAnimation alpha = new AlphaAnimation(0.0F, 1.0F); alpha.setDuration(PhotoDisplayFragment.FADE_DURATION); // Make animation instant alpha.setFillAfter(true); this._photoOptionsBar.startAnimation(alpha); this._optionsShowing = true; }
When I load it into an IceCream sandwich, LinearLayout exists because you can click the buttons and it performs their function, and the functions to display are called, but I just can't see them!
Any help would be great
source share