我想做一個TranslateAnimation但不能正常工作佈局apear和disapear但沒有做任何動畫。我怎麼能解決這個問題? Java代碼是這樣的:滑出滾動佈局動畫android
private void initComponents() {
ImageView postIV = (ImageView) findViewById(R.id.post_view_activity_image_iv);
CropBottonTransformation cropBottomTransformation = new CropBottonTransformation();
Picasso.with(context).load(bundle.getString(Constants.POST_IMAGE))
.centerCrop().fit().placeholder(R.drawable.home_placeholder)
.into(postIV);
TextView postTitleTV = (TextView) findViewById(R.id.post_view_activity_title_tv);
postTitleTV.setText(bundle.getString(Constants.POST_TITLE));
ObservableScrollView scroll = (ObservableScrollView) findViewById(R.id.post_view_activity_scroll);
scroll.setScrollViewListener(this);
hidenOptionsLL = (LinearLayout) findViewById(R.id.post_view_activity_slide_options);
hidenOptionsHeight = hidenOptionsLL.getHeight();
slideRL = (RelativeLayout) findViewById(R.id.post_view_activity_slide_rl);
}
...
@Override
public void onScrollChanged(ObservableScrollView scrollView, int x, int y,
int oldx, int oldy) {
if (y > oldy) {
if (sliding == false) {
// Animation animation =
// AnimationUtils.loadAnimation(context,
// R.anim.slide_in_out);
Animation animation = new TranslateAnimation(0, 0,
hidenOptionsHeight, 0);
animation.setInterpolator(new AccelerateInterpolator(1.0f));
animation.setDuration(600);
hidenOptionsLL.startAnimation(animation);
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
sliding = true;
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animation animation) {
sliding = false;
hidenOptionsLL.setVisibility(View.GONE);
}
});
}
} else if (y < oldy) {
if (sliding == false) {
// Animation animation =
// AnimationUtils.loadAnimation(context,
// R.anim.slide_in_out);
Animation animation = new TranslateAnimation(0, 0, 0,
hidenOptionsHeight);
hidenOptionsLL.setVisibility(View.VISIBLE);
animation.setInterpolator(new AccelerateInterpolator(1.0f));
animation.setDuration(600);
hidenOptionsLL.startAnimation(animation);
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
sliding = true;
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animation animation) {
sliding = false;
}
});
}
}
}
佈局是這樣的:
<LinearLayout
android:id="@+id/post_view_activity_slide_options"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:orientation="horizontal"
android:visibility="gone" >
<ImageButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@android:color/transparent"
android:src="@android:drawable/arrow_down_float" />
<ImageButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@android:color/transparent"
android:src="@android:drawable/arrow_up_float" />
<ImageButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@android:color/transparent"
android:src="@android:drawable/ic_delete" />
<ImageButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@android:color/transparent"
android:src="@android:drawable/btn_radio" />
</LinearLayout>
我沒有找到任何解決方案。我希望它能像谷歌搜索應用程序底部顯示的選項一樣工作。