我有一个ListView
,我从大约10列的数据表中加载数据,所以我需要用户能够水平滚动才能看到所有数据。现在我想将列放在ListView
之上,但在水平滚动内。不幸的是,我无法弄清楚如何将TextBoxes
置于ListView
之上,而是置于水平滚动之内。它总是将ListBox
推到TextBoxes
的同一级别。甚至有可能做到这一点?
我的XML代码如下:
<HorizontalScrollView
android:id="@+id/horizontalScrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/imageView2" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="527dp"
android:orientation="horizontal" >
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50sp"
android:layout_weight="1"
android:headerDividersEnabled="true" >
</ListView>
<TextView
android:id="@+id/code"
android:layout_width="110sp"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_marginStart="1dp"
android:layout_alignParentTop="true"
android:maxLines="1"
android:text="@string/lChangedTime"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="17sp" />
<TextView
android:id="@+id/manufacturer"
android:layout_width="70sp"
android:layout_height="wrap_content"
android:layout_marginLeft="11dp"
android:maxLines="1"
android:text="manufacturer"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="17sp" />
<TextView
android:id="@+id/name"
android:layout_width="200sp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="11dp"
android:layout_toRightOf="@+id/manufacturer"
android:maxLines="1"
android:text="@string/lCustomerName"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="20sp" />
<TextView
android:id="@+id/visc40"
android:layout_width="50sp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="11dp"
android:layout_toRightOf="@+id/name"
android:maxLines="1"
android:text="visc40"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="17sp" />
<TextView
android:id="@+id/visc100"
android:layout_width="50sp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="11dp"
android:layout_toRightOf="@+id/visc40"
android:maxLines="1"
android:text="visc100"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="17sp" />
</LinearLayout>
</HorizontalScrollView>
答案 0 :(得分:1)
如果我理解正确,那么您需要将文本视图嵌套在另一个布局中。
让我告诉你我的意思
<HorizontalScrollView
android:id = "@+id/horizontalScrollView1"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:layout_alignParentLeft = "true"
android:layout_alignParentRight = "true"
android:layout_below = "@+id/imageView2">
<LinearLayout
android:layout_width = "match_parent"
android:layout_height = "527dp"
android:orientation = "vertical">
<LinearLayout
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:orientation = "horizontal">
<TextView
android:id = "@+id/code"
android:layout_width = "110sp"
android:layout_height = "wrap_content"
android:layout_marginLeft = "0dp"
android:layout_marginStart = "1dp"
android:layout_alignParentTop = "true"
android:maxLines = "1"
android:text = "@string/lChangedTime"
android:textAppearance = "?android:attr/textAppearanceLarge"
android:textSize = "17sp"/>
<TextView
android:id = "@+id/manufacturer"
android:layout_width = "70sp"
android:layout_height = "wrap_content"
android:layout_marginLeft = "11dp"
android:maxLines = "1"
android:text = "manufacturer"
android:textAppearance = "?android:attr/textAppearanceLarge"
android:textSize = "17sp"/>
<TextView
android:id = "@+id/name"
android:layout_width = "200sp"
android:layout_height = "wrap_content"
android:layout_alignParentTop = "true"
android:layout_marginLeft = "11dp"
android:layout_toRightOf = "@+id/manufacturer"
android:maxLines = "1"
android:text = "@string/lCustomerName"
android:textAppearance = "?android:attr/textAppearanceLarge"
android:textSize = "20sp"/>
<TextView
android:id = "@+id/visc40"
android:layout_width = "50sp"
android:layout_height = "wrap_content"
android:layout_alignParentTop = "true"
android:layout_marginLeft = "11dp"
android:layout_toRightOf = "@+id/name"
android:maxLines = "1"
android:text = "visc40"
android:textAppearance = "?android:attr/textAppearanceLarge"
android:textSize = "17sp"/>
<TextView
android:id = "@+id/visc100"
android:layout_width = "50sp"
android:layout_height = "wrap_content"
android:layout_alignParentTop = "true"
android:layout_marginLeft = "11dp"
android:layout_toRightOf = "@+id/visc40"
android:maxLines = "1"
android:text = "visc100"
android:textAppearance = "?android:attr/textAppearanceLarge"
android:textSize = "17sp"/>
</LinearLayout>
<ListView
android:id = "@+id/listView1"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_marginTop = "50sp"
android:layout_weight = "1"
android:headerDividersEnabled = "true">
</ListView>
</LinearLayout>
</HorizontalScrollView>