姿态问题图形页面中viewpager页姿态、图形、页面、问题

由网友(ミ弑桖龍鯎)分享简介:我的应用程序的主界面是一个viewpager,用户只需滑动页面水平才能到各个页面。其中一个网页有一个谷歌图形页面(粘贴下面)。我的问题是,如果用户是在地图页上,并使用一个水平滑动的手势,页滑动到下一个页面,而不是在地图侧向运动。这是因为如果该viewpager越来越手势地图前。如果用户聪明并开始滑动地图中的对角线或垂直...

我的应用程序的主界面是一个viewpager,用户只需滑动页面水平才能到各个页面。其中一个网页有一个谷歌图形页面(粘贴下面)。我的问题是,如果用户是在地图页上,并使用一个水平滑动的手势,页滑动到下一个页面,而不是在地图侧向运动。这是因为如果该viewpager越来越手势地图前。

如果用户聪明并开始滑动地图中的对角线或垂直方向上的地图开始移动,然后所述手势可以继续水平。不过,我想preFER地图上移动,而不是在页面上简单的水平滑动的手势。页面总是可以使用TextView的下滑。

有没有什么办法可以做到这一点? 谢谢, 加里

 < XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
机器人:ID =@ + ID /的ContentPanel
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:方向=垂直>

 <的TextView
    机器人:ID =@ + ID / tvMAP
    机器人:layout_width =match_parent
    机器人:layout_height =WRAP_CONTENT
    机器人:文本=地图
    风格=@风格/ bigtype/>


< com.google.android.maps.MapView
    机器人:ID =@ + ID /图形页面
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT
    机器人:apiKey =mykeygoeshere
    机器人:可点击=真/>

< / LinearLayout中>
 

解决方案

当然有:

 公共类CustomViewPager扩展ViewPager {

    公共CustomViewPager(上下文的背景下){
        超(上下文);
    }

    公共CustomViewPager(上下文的背景下,ATTRS的AttributeSet){
        超(背景下,ATTRS);
    }

    @覆盖
    保护布尔canScroll(视图V,布尔checkV,INT DX,诠释的x,int y)对{
        如果(V的instanceof的MapView){
            返回true;
        }
        返回super.canScroll(ⅴ,checkV,DX,X,Y);
    }

}
 
Android开发中ViewPager实现多页面切换效果

这将会使地图忽略所有地图内的滑梯和斤斤计较的地图之外,幻灯片/ draggs。希望它能帮助。 (我这样做是正确的,现在与水平滚动一个web视图)

编辑:忘了提,而不是ViewPager,你需要使用CustomViewPager在YOUT布局

 < com.yourpackage.CustomViewPager
            机器人:ID =@ + ID / viewpager
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =FILL_PARENT
        />
 

My app's main interface is a viewpager where the user just slides the pages horizontally to get to the various pages. One of the pages has a google mapview (pasted below). My problem is that if the user is on the map page and uses a horizontal slide gesture, the page slides to the next page instead of the map moving sideways. It's as if the viewpager is getting the gesture before the map.

If the user is clever and begins sliding the map in a diagonal or vertical direction the map begins moving and then the gesture can continue horizontally. But I would prefer the map move instead of the page on a simple horizontal slide gesture. The page can always be slid using the textview.

Is there any way I can make this happen? thanks, Gary

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ContentPanel"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

 <TextView
    android:id="@+id/tvMAP"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Map"
    style="@style/bigtype" />


<com.google.android.maps.MapView
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:apiKey="mykeygoeshere"
    android:clickable="true" />

</LinearLayout>

解决方案

Of course there is:

public class CustomViewPager extends ViewPager {

    public CustomViewPager(Context context) {
        super(context);
    }

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

    @Override
    protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
        if(v instanceof MapView){
            return true;
        }
        return super.canScroll(v, checkV, dx, x, y);
    }

}

This will make the map ignore all the slides inside the map and just care about the slides/draggs outside the map. Hope it helps. (I do this right now for a webview with horizontal scroll)

EDIT: Forgot to mention that instead of the ViewPager you need to use the CustomViewPager in yout layout.

<com.yourpackage.CustomViewPager
            android:id="@+id/viewpager"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" 
        />

阅读全文

相关推荐

最新文章