简体   繁体   English

Android中整个布局上的滚动条

[英]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.

相关问题 为什么在Android Studio中不显示模拟器的整个布局? - Why shows the emulator not the whole layout in Android Studio? android适合图像填充整个布局 - android fit image to fill whole layout 在折叠栏布局android中向上滚动时淡化整个布局 - Fading the whole layout as scrolled up in collapsing bar layout android 我是否应该能够在Eclipse Graphical Layout中看到android滚动条? - Am I supposed to be able to see the android scrollbar in the Eclipse Graphical Layout? 具有自定义布局的Android ActionBar不会占据父级的整个宽度 - Android ActionBar with custom layout does not occupy whole width of parent 如何使用 layoutDirection 在 Android 中动态镜像整个布局? - How to use layoutDirection to mirror the whole layout dynamically in Android? Android / Java:EditText焦点会移动整个布局,只有ScrollView应该是 - Android/Java: EditText focus moves whole layout, and only ScrollView should be Android:如何在布局已经包含按钮的情况下以编程方式通过视图覆盖整个布局? - Android: How to cover the whole layout by a view programatically while the layout contains buttons already? 打印整个程序布局 - Print the whole program layout 如何将滚动条添加到Vaadin布局 - How to add scrollbar to Vaadin layout
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM