gpt4 book ai didi

android - AlphaAnimation 在 Ice Cream Sandwich 中不起作用

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:05:52 24 4
gpt4 key购买 nike

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

当前的解决方案在我的两台使用 Gingerbread 的设备和一台使用 Froyo 的设备上运行良好。然而,它不适用于 Ice Cream Sandwich ?!

这是我的 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>

这是我的 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);

然后当我想显示它时,我调用以下命令。

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;
}

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

任何帮助都会很棒

最佳答案

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

关于android - AlphaAnimation 在 Ice Cream Sandwich 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13028793/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com