gpt4 book ai didi

Android ViewSwitcher 多 View

转载 作者:行者123 更新时间:2023-11-29 15:19:59 25 4
gpt4 key购买 nike

我这样使用 ViewSwitcher:

<ViewSwitcher
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/content_popup"
android:visibility="invisible"
android:layout_centerInParent="true">

<include layout="@layout/content_popup_stub" android:id="@+id/content_general"/>
<include layout="@layout/video_select_popup_stub" android:id="@+id/content_select_video"/>

</ViewSwitcher>

并计划在该 ViewSwitcher 中使用 4 个子级。现在,如何使用 .showNext().showPrevious() 在 vi​​ew1 和 view 4 或 view1 和 view3 之间切换?有没有办法设置下一个或上一个 View ?

最佳答案

在此处找到的文档:

http://developer.android.com/reference/android/widget/ViewSwitcher.html

声明 View 切换器是一个在 2 个 View (不超过 2 个)之间切换的组件。如果你想在超过 2 个 View 之间切换,那么我建议你使用 ViewFlipper

http://developer.android.com/reference/android/widget/ViewFlipper.html

它是从 ViewAnimator 扩展而来的。它有一个名为 setDisplayedChild

的方法

(http://developer.android.com/reference/android/widget/ViewAnimator.html#setDisplayedChild(int))

您可以使用它在您拥有的不同 View 之间设置动画。它的实现与 ViewSwitcher 几乎相同。

希望这对您有所帮助。

关于Android ViewSwitcher 多 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19246637/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com