我有一個LinearLayout,在我的xml文件中創建,其可見性設置爲Gone
。然後我使用動畫展示它,這很好。在動畫之後設置LinearLayout的可見性
我淡出我的LinearLayout
使用AlphaAnimation
,這工作正常。
我的問題
但問題是,當我使用AnimationListener
和onAnimationEnd
方法被調用聽動畫,它並沒有我LinearLayout
的可見性設置爲GONE
,因爲我仍然可以點擊它在裏面,這是我知道他們仍然在那裏。
這是我的xml與我的LinearLayout。
<LinearLayout
android:id="@+id/photoOptionBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:alpha="1"
android:background="@color/gpsBackground"
android:orientation="horizontal"
android:visibility="gone">
<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>
這是我的淡出方法以及監聽器。
AlphaAnimation alpha = new AlphaAnimation(1.0F, 0.0F);
alpha.setDuration(PhotoDisplayFragment.FADE_DURATION); // Make animation instant
alpha.setFillAfter(true); // Tell it to persist after the animation ends
// And then on your layout
final LinearLayout temp = this._photoOptionsBar;
alpha.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
temp.setVisibility(View.GONE);
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
});
this._photoOptionsBar.startAnimation(alpha);
我的問題
如何設置動畫結束後,我LinearLayout
到GONE
的知名度?
預先感謝
刪除setFillAfter。你選擇的方式是正確的 – Blackbelt
我需要setFillAfter,所以當我想淡入它的阿爾法是0 – StuStirling
只需檢查photoOptionsBar可見性並應用fidein動畫。新的AlphaAnimation(0.0F,1.0F); – Blackbelt