27 列表格,您可以水平滚动查看
我知道这个问题已经在这个网站上得到了零碎的回答,我所有与此类似的问题的谷歌链接都是紫色的,我别无选择,只能在这里提问。
我想制作一个可以向左或向右滚动的表格,我遇到的问题是,当我添加多个列时,而不是添加均匀大小的列,它们只是在窗口中聚集在一起,并且滚动视图不执行任何操作。我的 .class 代码如下所示:
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
this.setContentView(R.layout.table);
}
我尝试构建的 XML 如下所示:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:shrinkColumns="*"
android:stretchColumns="*">
<TableRow
android:id="@+id/tableRow4"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:id="@+id/textView9"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:typeface="serif"
android:textSize="18dp"
android:text="Argos Tracking Data"
android:gravity="center"
android:layout_span="6"></TextView>
</TableRow>
<TableRow
android:id="@+id/tableRow1"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<TextView
android:id="@+id/TextView04"
android:text=""></TextView>
<TextView
android:id="@+id/TextView04"
android:text="Depth (FT)"
android:textSize="11dp"
android:textStyle="bold"
android:typeface="serif"></TextView>
<TextView
android:id="@+id/TextView03"
android:text="Temp (ºC)"
android:textSize="11dp"
android:textStyle="bold"
android:typeface="serif"></TextView>
<TextView
android:id="@+id/TextView02"
android:text="Mag. Field (nT)"
android:textSize="11dp"
android:textStyle="bold"
android:typeface="serif"></TextView>
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:id="@+id/tableRow2"
android:layout_width="match_parent">
<TextView
android:text="Day 1"
android:id="@+id/textView2"
android:textStyle="bold"></TextView>
<TextView
android:id="@+id/textView3"
android:text="28"
android:gravity="center_horizontal"></TextView>
<TextView
android:text="37"
android:id="@+id/textView4"
android:gravity="center_horizontal"></TextView>
<TextView
android:text="23°F"
android:id="@+id/textView5"
android:gravity="center_horizontal"></TextView>
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:id="@+id/tableRow2"
android:layout_width="match_parent">
<TextView
android:text="Day 2"
android:id="@+id/textView2"
android:textStyle="bold"></TextView>
<TextView
android:text="15"
android:id="@+id/textView3"
android:gravity="center_horizontal"></TextView>
<TextView
android:text="38"
android:id="@+id/textView4"
android:gravity="center_horizontal"></TextView>
<TextView
android:text="3°F"
android:id="@+id/textView5"
android:gravity="center_horizontal"></TextView>
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center">
</TableRow>
</TableLayout>
</ScrollView>
我想添加更多列,但是当我添加更多列时,数据只是挤在屏幕上,它不会均匀分布,并且不用说我用 XML 编写代码的方式,它根本不会滚动。有人可以帮助我并告诉我这里哪里出了问题吗?抱歉,如果这与其他帖子类似,我只是陷入困境,无法操纵我找到的任何答案来完成此任务。谢谢
I know this has been answered in bits and pieces around this site, all my google links to questions similar to this one are purple, i've no other choice but to ask it here.
I want to make a table I can scroll left or right through, the problem I am encountering is that when I add multiple columns, instead of adding even sized columns, they just bunch up in the window, and the scrollview does nothing. My .class code looks like this:
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
this.setContentView(R.layout.table);
}
My XML where I'm attempting to build this looks like this:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:shrinkColumns="*"
android:stretchColumns="*">
<TableRow
android:id="@+id/tableRow4"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:id="@+id/textView9"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:typeface="serif"
android:textSize="18dp"
android:text="Argos Tracking Data"
android:gravity="center"
android:layout_span="6"></TextView>
</TableRow>
<TableRow
android:id="@+id/tableRow1"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<TextView
android:id="@+id/TextView04"
android:text=""></TextView>
<TextView
android:id="@+id/TextView04"
android:text="Depth (FT)"
android:textSize="11dp"
android:textStyle="bold"
android:typeface="serif"></TextView>
<TextView
android:id="@+id/TextView03"
android:text="Temp (ºC)"
android:textSize="11dp"
android:textStyle="bold"
android:typeface="serif"></TextView>
<TextView
android:id="@+id/TextView02"
android:text="Mag. Field (nT)"
android:textSize="11dp"
android:textStyle="bold"
android:typeface="serif"></TextView>
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:id="@+id/tableRow2"
android:layout_width="match_parent">
<TextView
android:text="Day 1"
android:id="@+id/textView2"
android:textStyle="bold"></TextView>
<TextView
android:id="@+id/textView3"
android:text="28"
android:gravity="center_horizontal"></TextView>
<TextView
android:text="37"
android:id="@+id/textView4"
android:gravity="center_horizontal"></TextView>
<TextView
android:text="23°F"
android:id="@+id/textView5"
android:gravity="center_horizontal"></TextView>
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:id="@+id/tableRow2"
android:layout_width="match_parent">
<TextView
android:text="Day 2"
android:id="@+id/textView2"
android:textStyle="bold"></TextView>
<TextView
android:text="15"
android:id="@+id/textView3"
android:gravity="center_horizontal"></TextView>
<TextView
android:text="38"
android:id="@+id/textView4"
android:gravity="center_horizontal"></TextView>
<TextView
android:text="3°F"
android:id="@+id/textView5"
android:gravity="center_horizontal"></TextView>
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center">
</TableRow>
</TableLayout>
</ScrollView>
I want to add more columns, but when I add more, the data just crams on the screen, it doesnt spread out evenly, and needless to say the way I have the code written in the XML, it won't scroll at all. Can someone aide me and show me where i'm going wrong here? Sorry If this is similar to other posts, i'm just stuck and can't manipulate any answers ive found to accomplish this. Thx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ScrollView 没有方向属性。
只需将 ScrollView 替换为 HorizontalScrollView
ScrollView doesn't have an orientation attribute.
Just replace ScrollView with HorizontalScrollView