首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >固定区段标题可滚动的TableLayout

固定区段标题可滚动的TableLayout
EN

Stack Overflow用户
提问于 2012-07-31 18:15:36
回答 3查看 4.9K关注 0票数 0

我正在尝试创建一个这样的视图:

...that有两个固定的头部。整个表格布局是可滚动的,内部表格视图也是可滚动的,如图所示。标头和数据是动态的。当我向上滚动到header-2时,它隐藏了header-1的项目,而不是header-1。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2012-07-31 18:32:46

我可以向您解释如何在不使用ListView的情况下通过轻松完成此任务。对于较少的数据量,您不应该使用ListView,这将影响您的效率。

第1步:

使用weight属性,并为两个标头分配相等的一半

第2步:

标头名称为静态,在滚动视图中创建一个TableLayout

第3步:

创建TableRow作为动态是独立的或在相同的布局,并动态添加表行到TableLayout中。

对您将获得的第二个标头重复相同的操作。

For Dynamic TableLayout check this link

票数 0
EN

Stack Overflow用户

发布于 2012-07-31 18:17:30

代码语言:javascript
复制
 <?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="list1" />
<ListView
    android:id="@+id/list1"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:scrollbars="vertical" />
<View
    android:layout_width="fill_parent"
    android:layout_height="2dp"
    android:background="#FF4500" />
<TextView
    android:id="@+id/textView1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="list2" />
<ListView
    android:id="@+id/con_listView"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:scrollbars="vertical" />

票数 0
EN

Stack Overflow用户

发布于 2012-07-31 18:19:29

为此,您需要维护一个适配器类。这样您就可以根据需要对齐元素

检查this

this

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11737868

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档