简体   繁体   English

如何在Android中的视图分页器中创建滑块

[英]how to create slider in view pager in Android

I want to implement view pager in Android.But i want to create layout something like this 我想在Android中实现视图寻呼机。但是我想创建这样的布局 在此处输入图片说明

I m trying but left side and right side half image is not showing with current page .Can someone help how to work with this.Thanks to appreciate. 我正在尝试,但当前页面的左侧和右侧的一半图像未显示。有人可以帮助您进行此操作。谢谢。

In older to do that you will have to create your own custom ViewPager or you can use one of the libraries present out there. 在较早的版本中,您将必须创建自己的自定义ViewPager,或者可以使用那里提供的一种库。 I would recommend using MultiViewPager which is easy to use and is also lightweight. 我建议您使用MultiViewPager ,它既易于使用,又重量轻。

In order to use this library, download it and add it in your project and then simply add the following View in your Layout: 为了使用此库,请下载它并将其添加到您的项目中,然后只需在布局中添加以下视图:

<com.pixplicity.multiviewpager.MultiViewPager
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_marginTop="16dp"
    android:layout_weight="1"
    app:matchChildWidth="@+id/child_view_to_match" />

NOTE : Be sure to declare the app namespace: 注意 :请确保声明应用程序名称空间:

xmlns:app="http://schemas.android.com/apk/res-auto"

This is the end result: 这是最终结果:

例

Hope it helps! 希望能帮助到你! :) :)

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

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