[英]Scrollbar on the whole Layout in Android
I have an issue with the Android layout. 我的Android布局有问题。
I have some components (here a TableLayout and then a ListView). 我有一些组件(这里是TableLayout,然后是ListView)。 My scrollbar is associated only with the ListView and not the the TableLayout.
我的滚动条仅与ListView关联,而不与TableLayout关联。 As my TableLayout will become longer and in that case, my Listview will be unreadable.
由于我的TableLayout将变得更长,在这种情况下,我的Listview将变得不可读。
How can I have a scrollbar for the whole page and not only for the ListView ? 如何为整个页面(不仅是ListView)提供滚动条?
My code : 我的代码:
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="77dp" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:layout_column="1"
android:text="@string/client"
android:width="100px" />
<TextView
android:id="@+id/client"
android:layout_column="2"
android:width="200px" />
</TableRow>
</TableLayout>
<ListView
android:id="@+id/lstPointsVerification"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" >
</ListView>
Here is the code of each line of the ListView 这是ListView每行的代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tvDate"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
style="@style/ListePrincipal"
/>
How I correct that behaviour ? 我该如何纠正这种行为?
Regards 问候
You can do one thing that is create a seperate Layout for the Header
part that is the part above the ListView
and add it to the ListView
using ListView.addHeader(View);
您可以做一件事,即为
Header
部分(位于ListView
上方的部分)创建单独的Layout,然后使用ListView.addHeader(View);
将其添加到ListView
ListView.addHeader(View);
. 。 So, in that case your Layout will scroll with the
ListView
. 因此,在这种情况下,您的Layout将与
ListView
滚动。
Better put TableLayout inside ScrollView.
最好将TableLayout放在ScrollView中。 set height to scrollview.
将高度设置为scrollview。
You should not put ListView inside ScrollView 您不应该将ListView放在ScrollView中
Please see Scroll View in Scroll View is not possible in android, you can implement it but it not work. 请在Android中无法使用Scroll View中的Scroll View,您可以实现它,但不起作用。 According to your question, there is only one answer is feasible, we can have two linear layout of fixed height, and then add table layout and listview to these layouts.
根据您的问题,只有一个可行的答案,我们可以有两个固定高度的线性布局,然后将表格布局和listview添加到这些布局中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.