AlphaAnimation不适用于冰淇淋三明治

Stu*_*ing 4 android android-linearlayout android-4.0-ice-cream-sandwich

我通过使用操纵其alpha级别来显示具有淡入淡出动画的布局AlphaAnimation.

目前的解决方案适用于我使用Gingerbread的两个设备和使用Froyo的设备.但是,它不适用于冰淇淋三明治?!

这是我的xml布局.

<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>
Run Code Online (Sandbox Code Playgroud)

这是我的onCreate方法在加载时将alpha设置为0,就像在xml中完成它不起作用...

    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);
Run Code Online (Sandbox Code Playgroud)

然后,当我想展示它时,我打电话给以下.

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;
}
Run Code Online (Sandbox Code Playgroud)

当我在IceCream三明治中加载它时,LinearLayout就在那里,因为你可以点击按钮并执行它们的功能,并且正在调用要显示的功能但是我看不到它!

任何帮助都会很棒

Ava*_*i Y 6

问题android:alpha=0出在线性布局中.要使工作正常,您必须将可见性属性设置为在布局xml中不可见.并在开始alpha动画调用之前setVisibility(View.VISIBLE)