ScrollView android内的Horizo​​ntalScrollView [英] HorizontalScrollView inside a ScrollView android

查看:68
本文介绍了ScrollView android内的Horizo​​ntalScrollView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VerticalScrollView中有一个Horizo​​ntalScrollView.如果我水平滚动,则滚动是平滑的.但是,如果我垂直滚动,则滚动不平滑,有时会水平滚动.如何使垂直滚动平滑?

I have a HorizontalScrollView inside a VerticalScrollView. If I scroll Horizontally , the scrolling is smooth. But if I scroll Vertically , the scroll is not smooth, it is getting scrolled horizontally sometimes. How to make the vertical scroll smooth ?

这是我的xml

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.sasank.calendarview.MainActivity"
    android:background="@android:color/white">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="500dp"
        android:layout_marginLeft="200dp"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="20dp">
        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scrollbars="vertical">
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">
                <android.support.v7.widget.RecyclerView
                    android:id="@+id/chapter_list"
                    android:layout_width="150dp"
                    android:layout_height="match_parent">

                </android.support.v7.widget.RecyclerView>

                <HorizontalScrollView
                    android:id="@+id/horizontal_scroll"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_toRightOf="@id/chapter_list"
                    android:scrollbars="horizontal">
                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/calendar"
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent">

                    </android.support.v7.widget.RecyclerView>
                </HorizontalScrollView>

            </RelativeLayout>
        </ScrollView>

    </RelativeLayout>
</RelativeLayout>

我将Vertical LinearLayoutManager用于Chapter_list Recyclerview,将GridLayoutManager用于Calendar RecyclerView

Im using a Vertical LinearLayoutManager for Chapter_list Recyclerview and GridLayoutManager for Calendar RecyclerView

推荐答案

android:nestedScrollingEnabled="true"

您可以尝试执行此操作,但实际上与嵌套滚动等相关的问题仍然很常见.人们在StackOverflow上也遇到了同样的问题,请看一下,希望对您有所帮助:嵌套滚动问题

You can try this, but still problems connected to the nested scrolling and so on are actually common. People have had the same problems here on StackOverflow, take a look, i hope it can help you: Problems with Nested Scrolling

这篇关于ScrollView android内的Horizo​​ntalScrollView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆