Scrolling vertically and horizontally
I have quite a common problem, I guess.
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?
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.
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 o开发者_运维百科f the three horizontal pages.
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?
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...
Something like this:
<?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>
精彩评论