简体   繁体   English

如何在Android中使用动画调整ViewPager的大小

[英]How can I resize ViewPager with animation in Android

I'm beginner in Android and I have a little problem with animations yet. 我是Android的初学者,但是动画方面还是有一些问题。 I have a layout in Android with a viewpager (the pink part of the layout): 我在Android中有一个带有viewpager的布局(布局的粉红色部分):
Android ViewPager layout Android ViewPager布局
I would like to resize the height of the viewpager with an animation when user clicking on the Skip button like this one: 当用户单击“跳过”按钮时,我想用动画来调整viewpager的高度:
enter image description here 在此处输入图片说明
I've tried to set the layoutparams of the view, but I got an error: 我尝试设置视图的layoutparams,但是出现错误:

java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to android.widget.FrameLayout$LayoutParams

You get the error probably because you cast (LinearLayoutParams)yourViewPager.getLayoutParams(); 您得到错误的原因可能是因为您投射(LinearLayoutParams)yourViewPager.getLayoutParams(); if you want to change the height use 如果要更改高度,请使用

yourViewPager.getLayoutParams().height=value;

if you want to animate it you can use value animators you can find a simple sample here also on github 如果您想对其进行动画处理,则可以使用值动画器,您也可以在github上找到一个简单的示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM