TableLayout ScrollView 垂直&水平的
我们如何垂直和滚动设置 ScrollView
水平的?我尝试了下面的代码,但它不起作用。
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/red"
android:scrollbarFadeDuration="1000"
android:scrollbarSize="12dip" >
<HorizontalScrollView
android:id="@+id/horizontalScrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:collapseColumns="2"
android:stretchColumns="1" >
</TableLayout>
</HorizontalScrollView>
<ScrollView >
</ScrollView>
这是我的所有代码:http://pastebin.com/ysRhLMyt
当前屏幕:
我想始终显示滚动条。
How we can setup ScrollView
vertically & horizontally? I tried the below code, but it didn't work.
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/red"
android:scrollbarFadeDuration="1000"
android:scrollbarSize="12dip" >
<HorizontalScrollView
android:id="@+id/horizontalScrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:collapseColumns="2"
android:stretchColumns="1" >
</TableLayout>
</HorizontalScrollView>
<ScrollView >
</ScrollView>
Here is all my code : http://pastebin.com/ysRhLMyt
Current screen :
I want to display scroll bar always.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试
设置 android:scrollbarFadeDuration="0"
<前><代码> 或
ScrollView1.setScrollbarFadingEnabled(false);
<前><代码> 或
android:scrollbarFadeDuration="0" 和
android:scrollbarAlwaysDrawVerticalTrack="true" 垂直
android:scrollbarAlwaysDrawHorizontalTrack="true" 水平
和还有一件事,
请记住,ScrollView 只能有一个子控件,因此我们可以创建一个容器(Linear、relative、Table布局)ScrollView 的子级并将所有控件放入该子级中。
供参考: http://android-pro.blogspot.com/2010/ 02/android-scrollview.html
Try,
Set the android:scrollbarFadeDuration="0"
ScrollView1.setScrollbarFadingEnabled(false);
android:scrollbarFadeDuration="0" and
android:scrollbarAlwaysDrawVerticalTrack="true" for vertical
android:scrollbarAlwaysDrawHorizontalTrack="true" for horizontal
And one more thing,
Remember, the ScrollView can have only one child control, so we can make a container (Linear, relative, Table Layouts) the child of the ScrollView and put all the controls inside this child.
For reference: http://android-pro.blogspot.com/2010/02/android-scrollview.html
嵌套滚动视图不起作用。它与滚动视图触摸处理有关:顶级视图始终消耗所有触摸事件。您必须编写自己的自定义滚动视图。
Nested scroll views doesn't work. It's related to scroll view touch handling: top level view always consume all touch events. You have to write you own custom scroll view.
下面的代码使水平和垂直滚动视图,
要查看其效果,请首先定义一个 200x 200 dp 周围的区域,并将此代码粘贴到其中。
视图将水平和垂直滚动。
Below code which makes horizontal and vertical scroll view,
To see its effect first define a area around 200x 200 dp and paste this code inside it.
The View will scrolling horizontally as well as vertically.
尝试使用
android:orientation
属性。这可用于水平或垂直:android:orientation="horizontal"
或android:orientation="vertical"
。Try using the
android:orientation
attribute. This can be used for horizontal or vertical:android:orientation="horizontal"
orandroid:orientation="vertical"
.