垂直和水平滚动 [英] Scrolling vertically and horizontally

查看:146
本文介绍了垂直和水平滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个相当普遍的问题,我猜。

I have quite a common problem, I guess.

我有一个活动和里面我需要三个屏幕。的问题是,它们可以/应当以两种方式(水平和垂直方向)滚动。由于嵌入 Horizo​​ntalScrollView 与正常滚动型通常气馁,通常会导致更多的问题比它解决的,还有没有其他的方法来实现这个,而无需编写自己的 SurfaceView 类和手工处理滚动?

I have an Activity and inside it I need three screens. The problem is, they can/should be scrolled in both ways (horizontally and vertically). Since embedding a HorizontalScrollView with a normal ScrollView is usually discouraged and typically causes more problems than it solves, are there any other ways to implement this without having to write your own SurfaceView class and handle the scrolling by hand?

我试过到目前为止是:
Horizo​​ntalScrollView 滚动型在对方镶嵌。它没有运作良好。虽然水平滚动工作了几乎完美的(几乎,因为我仍然可以看到甚至开始滚动前的第二个屏幕的一部分),垂直并没有在所有的工作(如预期),并部分覆盖屏幕。

What I've tried so far is: Have HorizontalScrollView and ScrollView embeded in each other. It didn't worked well. While horizontal scrolling was working almost perfectly (almost because I could still see a part of the second screen before even starting to scroll), vertical didn't work at all (as expected) and was partly covering the screen.

为code需要改变所有的3页/更新的观点我不能把它分成三个不同的活动。

I can't split it into three different activities, as the code requires to change/update views in all 3 pages.

<com.tseng.widget.TalentLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/TalentLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
>
    ... many dozen of other views here ...
</com.tseng.widget.TaletLayout>

这基本上是三横页面的每一个布局。

That's basically the layout of every single of the three horizontal pages.

什么是实现这个的最佳方式?如果没有其他解决办法不是写我自己的滚动功能,有没有什么好的教程或code,我可以看看?

What's the best way to implement this? If there is no other solution than writing my own scrolling features, is there any good tutorial or code I could look at?

推荐答案

据我所知,这是不可能创建水平和垂直滚动simultaneousnessly滚动型。至少不是那么容易。但是,您可以使用合并,但滚动仅局限于水平或垂直只...

To my knowledge it is not possible to create a scrollview that scrolls horizontally and vertically simultaneousnessly. At least not so easily. However you can use a merge, but scrolling is limited to just horizontal or just vertical...

事情是这样的:

<?xml version="1.0" encoding="utf-8"?>
<merge 
    android:id="@+id/merge"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <ScrollView android:id="@+id/ScrollView01" 

        <HorizontalScrollView 
        xmlns:android="http://schemas.android.com/apk/res/android"

            <TextView android:id="@+id/Text" 
            </TextView>

        </HorizontalScrollView>

    </ScrollView>
</merge>

这篇关于垂直和水平滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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