安卓桌面左右滑动时,会跟着一起左右变的圆圈是啥控件?怎么实现?图片的左右下角都有的

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了安卓桌面左右滑动时,会跟着一起左右变的圆圈是啥控件?怎么实现?图片的左右下角都有的相关的知识,希望对你有一定的参考价值。

这个叫做指示器,是为了标记左右桌面多少而设计的,现在你的所在桌面的左右各有2个桌面,很多第三方桌面,例如go桌面等都可以设置它是否显示,不喜欢可以隐藏

代码如下
android ViewPagerIndicator
==========================

Paging indicator widgets that are compatible with the `ViewPager` from the
[Android Support Library][2] to improve discoverability of content.

Try out the sample application [on the Android Market][10].

![ViewPagerIndicator Sample Screenshots][9]

These widgets can also be used in conjunction with [ActionBarSherlock][3]!

Usage
=====

*For a working implementation of this project see the `sample/` folder.*

1. Include one of the widgets in your view. This should usually be placed
adjacent to the `ViewPager` it represents.

<com.viewpagerindicator.TitlePageIndicator
android:id="@+id/titles"
android:layout_height="wrap_content"
android:layout_width="fill_parent" />

2. In your `onCreate` method (or `onCreateView` for a fragment), bind the
indicator to the `ViewPager`.

//Set the pager with an adapter
ViewPager pager = (ViewPager)findViewById(R.id.pager);
pager.setAdapter(new TestAdapter(getSupportFragmentManager()));

//Bind the title indicator to the adapter
TitlePageIndicator titleIndicator = (TitlePageIndicator)findViewById(R.id.titles);
titleIndicator.setViewPager(pager);

3. *(Optional)* If you use an `OnPageChangeListener` with your view pager
you should set it in the indicator rather than on the pager directly.

//continued from above
titleIndicator.setOnPageChangeListener(mPageChangeListener);

Theming
-------

There are three ways to style the look of the indicators.

1. **Theme XML**. An attribute for each type of indicator is provided in which
you can specify a custom style.
2. **Layout XML**. Through the use of a custom namespace you can include any
desired styles.
3. **Object methods**. Both styles have getters and setters for each style
attribute which can be changed at any point.

Each indicator has a demo which creates the same look using each of these
methods.

Including In Your Project
-------------------------

Android-ViewPagerIndicator is presented as an [Android library project][7]. A
standalone JAR is not possible due to the theming capabilities offered by the
indicator widgets.

You can include this project by [referencing it as a library project][8] in
Eclipse or ant.

If you are a Maven user you can easily include the library by specifying it as
a dependency:

<dependency>
<groupId>com.viewpagerindicator</groupId>
<artifactId>library</artifactId>
<version>2.4.1</version>
<type>apklib</type>
</dependency>

This project depends on the `ViewPager` class which is available in the
[Android Support Library][2] or [ActionBarSherlock][3]. Details for
including one of those libraries is available on their respecitve web sites.追问

能不能来个简单点的说法,我新手 没有怎么看懂你写的什么啊

追答

代码就是这样,如果你想自己实现,没有这个必要,这涉及到Android编译

参考技术A 打开桌面设置,在壁纸滑动(屏幕滑动时壁纸同时滑动)的选项打勾。注:不同的手机细节设置可能有点不同,但你能找到类似的设置。
望采纳。追问

大哥 我是想知道用安卓代码怎么实现这个功能!不是怎么设置!

参考技术B 这个圆圈叫做指示器,其作用是标记左右桌面多少而设计的,现在所在桌面的左右各有2个桌面,很多第三方桌面,例如go桌面等都可以设置它是否显示,不喜欢可以隐藏。
打开方法为:打开桌面设置,在壁纸滑动(屏幕滑动时壁纸同时滑动)的选项打勾。注:不同的手机细节设置可能有点不同。
代码如下:
Android ViewPagerIndicator
==========================

Paging indicator widgets that are compatible with the `ViewPager` from the
[Android Support Library][2] to improve discoverability of content.

Try out the sample application [on the Android Market][10].

![ViewPagerIndicator Sample Screenshots][9]

These widgets can also be used in conjunction with [ActionBarSherlock][3]!

Usage
=====

*For a working implementation of this project see the `sample/` folder.*

1. Include one of the widgets in your view. This should usually be placed
adjacent to the `ViewPager` it represents.

<com.viewpagerindicator.TitlePageIndicator
android:id="@+id/titles"
android:layout_height="wrap_content"
android:layout_width="fill_parent" />

2. In your `onCreate` method (or `onCreateView` for a fragment), bind the
indicator to the `ViewPager`.

//Set the pager with an adapter
ViewPager pager = (ViewPager)findViewById(R.id.pager);
pager.setAdapter(new TestAdapter(getSupportFragmentManager()));

//Bind the title indicator to the adapter
TitlePageIndicator titleIndicator = (TitlePageIndicator)findViewById(R.id.titles);
titleIndicator.setViewPager(pager);

3. *(Optional)* If you use an `OnPageChangeListener` with your view pager
you should ......

ListVIew中包含水平滑动控件,左右滑动时容易触发上下滑动

 

自定义ListView

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ListView;

public class LiveCustomListView extends ListView {
public LiveCustomListView(Context context) {
super(context);
}

public LiveCustomListView(Context context, AttributeSet attrs) {
super(context, attrs);
}

private float mLastX;
private float mLastY;

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
//避免左右滑动水平图片时容易触发上下滑动列表
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
mLastX = ev.getX();
mLastY = ev.getY();
break;
case MotionEvent.ACTION_MOVE:
if (Math.abs(mLastX - ev.getX()) > Math.abs(mLastY - ev.getY())) {
return false;
}
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
break;
}
return super.onInterceptTouchEvent(ev);
}
}

以上是关于安卓桌面左右滑动时,会跟着一起左右变的圆圈是啥控件?怎么实现?图片的左右下角都有的的主要内容,如果未能解决你的问题,请参考以下文章

Android复杂表格如何实现?

移动端轮播图左右滑动页面会抖是啥原因

仿探探左右滑动效果(兼容安卓,ios,小程序,h5)

ListVIew中包含水平滑动控件,左右滑动时容易触发上下滑动

Android中WebView和父控件滑动冲突

自定义ViewPager,避免左右滑动时与水平滑动控件冲突