【问题标题】:How can I resize ViewPager with animation in Android如何在 Android 中使用动画调整 ViewPager 的大小
【发布时间】:2017-01-12 10:43:39
【问题描述】:

我是 Android 的初学者,但我在动画方面还有点小问题。 我在 Android 中有一个带有 viewpager 的布局(布局的粉红色部分):
Android ViewPager layout
当用户单击像这样的跳过按钮时,我想用动画调整 viewpager 的高度:
enter image description here
我尝试设置视图的布局参数,但出现错误:

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

【问题讨论】:

    标签: android animation android-viewpager


    【解决方案1】:

    您收到错误可能是因为您投射 (LinearLayoutParams)yourViewPager.getLayoutParams(); 如果你想改变高度 使用

    yourViewPager.getLayoutParams().height=value;
    

    如果你想为它制作动画,你可以使用value animators 您也可以在 github

    上找到一个简单的示例

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-12
      • 2018-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-17
      • 2017-11-22
      • 2016-03-23
      相关资源
      最近更新 更多