布局可滚动android的一部分

鲁ck的塞尔吉奥

我正在尝试在Android应用程序中使用linearlayout滚动。我需要这种方式。

当用户向上滑动时,框1可以移出屏幕,框2应该固定在屏幕顶部,框3是可滚动的框。如何实现呢?我认为图像可以帮助您理解。

在此处输入图片说明

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >
<ScrollView
    android:id="@+id/scroller"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true" >
    <TableLayout
        android:id="@+id/tableLayout1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="26dp" >

        <TableRow
            android:id="@+id/tableRow1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <EditText
                android:id="@+id/editText1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Row1" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <EditText
                android:id="@+id/editText2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Row2" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <EditText
                android:id="@+id/editText3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Row3" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <EditText
                android:id="@+id/editText4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/tableLayout1"
                android:layout_alignRight="@+id/tableLayout1"
                android:layout_below="@+id/tableLayout1"
                android:ems="10"
                android:text="Row4" />
        </TableRow>
    </TableLayout>
</ScrollView>
    <TableLayout
        android:id="@+id/tableLayout2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/tableLayout2"
        android:layout_centerVertical="true"
        android:layout_marginLeft="49dp" >

        <TableRow
            android:id="@+id/tableRow5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <EditText
                android:id="@+id/editText5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/tableLayout1"
                android:layout_centerVertical="true"
                android:ems="10"
                android:text="Row5" />
        </TableRow>
    </TableLayout>

    <TableLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/tableLayout3"
        android:layout_below="@+id/tableLayout2"
        android:layout_marginTop="25dp" >

        <TableRow
            android:id="@+id/tableRow6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <EditText
                android:id="@+id/editText6"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Row6" >

                <requestFocus />
            </EditText>

        </TableRow>

        <TableRow
            android:id="@+id/tableRow7"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <EditText
                android:id="@+id/editText7"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" 
android:text="Row7" />

        </TableRow>

        <TableRow
            android:id="@+id/tableRow8"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <EditText
                android:id="@+id/editText8"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" 
                android:text="Row8" />

        </TableRow>

        <TableRow
            android:id="@+id/tableRow9"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <EditText
                android:id="@+id/editText9"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" 
                android:text="Row9" />

        </TableRow>
    </TableLayout>

</RelativeLayout>
鲁ck的塞尔吉奥

我实际上需要固定标头,并发现它更有用。

这个github项目实际上正在工作(仅在代码中进行了一些调整)。@rahulritesh链接也对我有帮助。但这对我来说更容易理解。

https://github.com/beworker/pinned-section-listview/

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Classloader是JVM的一部分还是JRE的一部分?

Android只能显示网站的一部分

为网页的一部分实现不同的布局

应用程序在网格布局声明的一部分中崩溃

Android,XML:在布局容器中仅显示图像的一部分,而不会更改纵横比

reactjs创建表的一部分可滚动

使屏幕的一部分在Flutter中可滚动

在“父级”布局中显示图像的一部分

我的代码的哪一部分使滚动条不显示?

如何在水平滚动网站中跳到页面的一部分?

取弦的一部分,并与另一部分

当网页只有一部分可滚动时如何滚动硒(python)

在Android中模糊图像的一部分

在Android中获取图片的一部分?

仅在情节提要的一部分上自动布局

滚动时如何捕获ScrollView的一部分?

PHP错误输出清除了我的html布局的一部分

组合键作为布局开关组合的一部分

让布局的一部分填充剩余空间的最佳方法是什么?

单滚动的全页视图移动到下一部分

保存布局到流。错误:找不到路径“c:\TreeListLayout\”的一部分

创建一个布局,其中一部分是静态的,另一部分在 Native-Base 中滑动时可滚动

在 WPF 中滚动时冻结画布的一部分?

如何滚动到 UITableView 中最后一部分的最后一行?

使用 kivy 使屏幕的一部分成为可滚动的图像

如何仅在布局的一部分上使用 WPF DataTemplates

Android 使布局变暗以强调另一部分

滚动后的下一部分

React Fullpage:如何滚动部分的一部分而不滚动整个部分