如何在滚动视图下放置新项目 [英] How can I place new items under scrollview

查看:78
本文介绍了如何在滚动视图下放置新项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个垂直滚动的布局,其中包含很多项目,工作正常.
我正在尝试在屏幕底部放置一个新的linearlayout,而不是可滚动布局的一部分.
也就是说,它将位于独立于可滚动部分的底部(如adview). 我只能将其放置在scrollView内.
如何将其放置在下面,使其始终可见?

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 ?

推荐答案

使用RelativeLayout并按以下方式组织它:

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>

技巧在ScrollView位置中,同时使其与屏幕顶部对齐,并在下部固定的LinearLayout上方.就是这样.

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.

这篇关于如何在滚动视图下放置新项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆