2
我想在我的android應用程序中有一個按鈕觸發一個窗體的向下滑動視圖。我想要在屏幕頂部顯示一個視圖,在屏幕底部顯示一個列表,並且我希望在點擊按鈕時在兩者之間出現滑動窗體。向下滑動視圖在android中
我沒有問題顯示視圖,但似乎無法將其從隱藏的動畫顯示在屏幕上顯示。
關於如何工作的任何想法?
我想在我的android應用程序中有一個按鈕觸發一個窗體的向下滑動視圖。我想要在屏幕頂部顯示一個視圖,在屏幕底部顯示一個列表,並且我希望在點擊按鈕時在兩者之間出現滑動窗體。向下滑動視圖在android中
我沒有問題顯示視圖,但似乎無法將其從隱藏的動畫顯示在屏幕上顯示。
關於如何工作的任何想法?
public void doSlideDown(View view){
RelativeLayout myView = (RelativeLayout)findViewById(R.id.my_view);
addListingView.setVisibility(myView.VISIBLE);
Animation slideDown = setLayoutAnim_slidedown();
myView.startAnimation(slideDown);
}
public void doSlideUp(View view){
RelativeLayout myView = (RelativeLayout)findViewById(R.id.my_view);
Animation slideUp = setLayoutAnim_slideup();
myView.startAnimation(slideUp);
}
public Animation setLayoutAnim_slidedown() {
AnimationSet set = new AnimationSet(true);
Animation animation = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
0.0f, Animation.RELATIVE_TO_SELF, -1.0f,
Animation.RELATIVE_TO_SELF, 0.0f);
animation.setDuration(800);
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
// MapContacts.this.mapviewgroup.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
Log.d("LA","sliding down ended");
}
});
set.addAnimation(animation);
LayoutAnimationController controller = new LayoutAnimationController(
set, 0.25f);
return animation;
}
public Animation setLayoutAnim_slideup() {
AnimationSet set = new AnimationSet(true);
Animation animation = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, -1.0f);
animation.setDuration(800);
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
RelativeLayout bodyView = (RelativeLayout)findViewById(R.id.bodyView);
RelativeLayout myView = (RelativeLayout)findViewById(R.id.my_view);
addListingView.clearAnimation();
bodyView.removeView(myView);
}
});
set.addAnimation(animation);
LayoutAnimationController controller = new LayoutAnimationController(
set, 0.25f);
return animation;
}
這正是我一直在尋找。謝謝! – 2015-06-21 10:50:15