如何在滚动视图下放置新项目

发布于 2024-12-18 19:13:48 字数 155 浏览 0 评论 0原文

我有一个包含很多项目的垂直可滚动布局,工作正常。
我正在尝试将一个新的线性布局放置到屏幕底部,该布局不会成为可滚动布局的一部分。
也就是说,它会位于底部(就像广告视图一样),独立于可滚动部分。 我只能将它放在滚动视图内。
如何将其放置在下面,以便它始终可见?

I have a vertical scrollable layout with lots of items, working fine.
I am trying to place a new linearlayout to the bottom of the screen that would NOT be part of the scrollable layout.
That is, it would sit on the buttom (like an adview) independent of the scrollable part.
I was only able to place it inside the scrollView.
How can I place it below, so it would always visible ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

诺曦 2024-12-25 19:13:48

使用RelativeLayout,并像这样组织它:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <ScrollView 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:layout_centerHorizontal="true"
        android:layout_alignParentTop="true"
        android:layout_above="@+id/linearLayoutThatDoesNotScroll" >

        <LinearLayout
            android:id="@+id/linearLayoutWithLotofContent"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >
        </LinearLayout>

    </ScrollView>

    <LinearLayout
        android:id="@+id/linearLayoutThatDoesNotScroll"  
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" 
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true" >
    </LinearLayout>

</RelativeLayout>

技巧在于ScrollView 的放置,同时它与屏幕顶部对齐并且位于下部固定的LinearLayout 上方。它就是有效的。

Use a RelativeLayout, and organize it like this:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <ScrollView 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:layout_centerHorizontal="true"
        android:layout_alignParentTop="true"
        android:layout_above="@+id/linearLayoutThatDoesNotScroll" >

        <LinearLayout
            android:id="@+id/linearLayoutWithLotofContent"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >
        </LinearLayout>

    </ScrollView>

    <LinearLayout
        android:id="@+id/linearLayoutThatDoesNotScroll"  
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" 
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true" >
    </LinearLayout>

</RelativeLayout>

The trick is in the ScrollView placement, at the same time it is aligned with the top of the screen AND above the lower, fixed, LinearLayout. It just works.

余生共白头 2024-12-25 19:13:48

像这样的:)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" >
    <ScrollView android:id="@+id/scroll_view"
        android:layout_width="fill_parent" 
        android:layout_height="0dp"
        android:layout_weight="1" >
        <LinearLayout android:id="@+id/content"
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" />
    </ScrollView>
    <LinearLayout android:id="@+id/bottom"
        android:layout_width="fill_parent" 
        android:layout_height="10dip" />          
</LinearLayout>

您将使用 android:id=bottom 将底部内容添加到底部 LinearLayout :)

something like this :)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" >
    <ScrollView android:id="@+id/scroll_view"
        android:layout_width="fill_parent" 
        android:layout_height="0dp"
        android:layout_weight="1" >
        <LinearLayout android:id="@+id/content"
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" />
    </ScrollView>
    <LinearLayout android:id="@+id/bottom"
        android:layout_width="fill_parent" 
        android:layout_height="10dip" />          
</LinearLayout>

You will add your bottom content to the bottom linearLayout with the android:id=bottom :)

与风相奔跑 2024-12-25 19:13:48

如果您使用垂直 LinearLayout 来保存可滚动布局,那么您可以将 adview 添加到可滚动布局下方的 LinearLayout 中,它将显示在屏幕底部。 (假设您的权重设置正确,并且滚动布局设置为WRAP_CONTENT

RelativeLayout将允许您将广告视图设置为与可滚动布局的底部对齐同样,但您仍然需要确保可滚动布局设置为 WRAP_CONTENT ,这样它就不会自动占据整个屏幕。

If you used a vertical LinearLayout to hold the scrollable layout, then you could add the adview to the LinearLayout below the scrollable layout and it would appear at the bottom of the screen. (assuming your weights are set correctly,and the scroll layout is set to WRAP_CONTENT)

A RelativeLayout would allow you to set the adview to align itself with the bottom of the scrollable layout as well, but you would still need to make sure the scrollable layout was set to WRAP_CONTENT so it didn't automatically take up the entire screen.

与君绝 2024-12-25 19:13:48
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <Button
        android:id="@+id/dialogButtonOK"
        android:layout_width="100px"
        android:layout_height="wrap_content"
        android:text=" Ok "
        android:layout_alignParentBottom="true"
        android:layout_centerInParent="true"
        android:background="@drawable/button_style"
        />
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:id="@+id/scrView"
        android:layout_above="@id/dialogButtonOK"
        android:layout_alignParentTop="true"
       >
            <HorizontalScrollView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" >
                      <TableLayout
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:stretchColumns="*"
                        android:id="@+id/main_table" >
                    </TableLayout>
            </HorizontalScrollView>
    </ScrollView>




</RelativeLayout>

这对我有用

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <Button
        android:id="@+id/dialogButtonOK"
        android:layout_width="100px"
        android:layout_height="wrap_content"
        android:text=" Ok "
        android:layout_alignParentBottom="true"
        android:layout_centerInParent="true"
        android:background="@drawable/button_style"
        />
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:id="@+id/scrView"
        android:layout_above="@id/dialogButtonOK"
        android:layout_alignParentTop="true"
       >
            <HorizontalScrollView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" >
                      <TableLayout
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:stretchColumns="*"
                        android:id="@+id/main_table" >
                    </TableLayout>
            </HorizontalScrollView>
    </ScrollView>




</RelativeLayout>

This is worked for me

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文