xml Пример: < /p>
Код: Выделить всё
< /code>
анимационный код: < /p>
//when user click,it will call this function
public void changeDialogHeight(int mode, double height) {
//mDialogView is the parent view of webView
ViewGroup.LayoutParams layoutParams = mDialogView.getLayoutParams();
int currentHeight = layoutParams.height;
int targetHeight = 0;
int screenHeight = Utils.getScreenHeight(BaseApplication.get());
switch (mode) {
case 0:
targetHeight = screenHeight;
break;
case 1:
targetHeight = screenHeight / 2;
break;
case 2:
if(height > Utils.getScreenHeight(mContext) || height < 50){
height = Utils.getScreenHeight(mContext) / 2;
}
targetHeight = (int)height;
break;
}
ValueAnimator valueAnimator = ValueAnimator.ofInt(currentHeight, targetHeight);
valueAnimator.setDuration(400);
valueAnimator.setInterpolator(new LinearInterpolator());
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
runOnUiThread(new Runnable() {
@Override
public void run() {
int animatedValue = (int) animation.getAnimatedValue();
layoutParams.height = animatedValue;
mDialogView.setLayoutParams(layoutParams);
}
});
}
});
valueAnimator.start();
}
Подробнее здесь: https://stackoverflow.com/questions/797 ... t-of-the-w
Мобильная версия