滚动 Android 视图/表单大于屏幕尺寸
我有视图/表单/活动,当以横向/水平模式显示时,变得比屏幕尺寸更大。我想知道用户可以向下滚动视图的方式是什么?
目前我所有的小部件都采用线性布局。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:isScrollContainer="true">
<Widget1></Widget1>
<Widget2></Widget2>
<Widget3></Widget3>
<Widget4></Widget4>
<Widget5></Widget5>
</LinearLayout>
I have view/form/activity, when displayed in landscape/horizontal mode, become bigger than screen size. I was wondering what is the way in which user can scroll down the view?
Currently all of my widgets are in the Linear layout as fellows.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:isScrollContainer="true">
<Widget1></Widget1>
<Widget2></Widget2>
<Widget3></Widget3>
<Widget4></Widget4>
<Widget5></Widget5>
</LinearLayout>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果我正确理解你的问题:你可以在 LinearLayout 外部有一个 ScrollView ,在 LinearLayout 内部有一个 HorizontalScrollView ,你可以在其中添加你的小部件。这将允许您从左向右和从上向下滚动。
示例代码:
If I understand your question correctly: you could have a ScrollView outside your LinearLayout and have a HorizontalScrollView inside your LinearLayout, where you could add your Widgets. This will allow you to scroll both left-right and top-down.
Example Code:
首先感谢 @Dimitris Makris 帮助我找到正确的方向并为我编写代码。但我为自己找到的正确解决方案是这样的。
First thanks for the @Dimitris Makris in helping me out to find the right direction and writing the code for me. But the correct solution which I have found for myself is this.
对我的情况有效的是将 ScrollView 作为最外面的视图,
接下来是 HorizontalScrollView,然后将所有内容都嵌套在里面。
*注意 - ScrollView 不支持水平滚动,因此需要嵌套 HorizontalScrollView。
What worked for my situation was to put the ScrollView as the outer-most view,
followed by HorizontalScrollView, and then nested everything inside.
*NOTE - ScrollView does not support horizontal scrolling, hence the nested HorizontalScrollView.