简体   繁体   English

Android中的自定义可滑动查看

[英]Custom Swipeable View in Android

I want to create a swipe-able view for showing status of user. 我想创建一个可滑动的视图以显示用户状态。 When user swipes status should change from active to inactive or vice versa. 当用户滑动时,状态应从活动变为非活动,反之亦然。 And I want this view to be only at max 70-80 dp in height. 我希望此视图的最大高度仅为70-80 dp。 How can I achieve this behavior ?? 我如何实现这种行为?

You can use ViewPager . 您可以使用ViewPager

It have built-in swipe gestures to transition through pages, and they display screen slide animations by default, so you don't need to create any. 它具有内置的滑动手势,可在页面之间切换,并且默认情况下会显示屏幕幻灯片动画,因此您无需创建任何动画。 ViewPagers use PagerAdapters as a supply for new pages to display . ViewPagers使用PagerAdapters作为要显示的新页面的供应。

<android.support.v4.view.ViewPager
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

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

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