I am display a layout with fade animation by manipulating its alpha levels using AlphaAnimation
.
The current solution works fine on two of my devices which use Gingerbread and one which uses Froyo. However, it does not work on 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 to 0 on loadup as when done in xml it doesn't 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 up in IceCream sandwich the LinearLayout is there because you can click the buttons and it executes their function, and the functions to show are being called but I just can't see it!
Any help would be great
The problem is with android:alpha=0
in the Linear Layout. To make things work you have to set visibility property to invisible in layout xml. And before starting alpha animation call setVisibility(View.VISIBLE)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With