与2调整视图创建一个Android布局 [英] Creating an Android Layout with 2 resizing views

查看:181
本文介绍了与2调整视图创建一个Android布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的布局,我需要一个头,一个列表视图,并以的TextView 页脚。在的TextView 必须可调整大小多达5行。认为Facebook聊天,在那里你必须与你的朋友的名字,中间的内容窗格中,和楼下一个文本框的蓝色标题,让我们从你输入的东西成长:

In my layout, I need a header, a list-view, and a footer with a TextView. The TextView needs to be resizable to up to 5 lines. Think facebook chat, where you have the blue header with the name of your friend, the middle content pane, and a text box down below, that grows as you type stuff in:

[header]     a fragment that takes up about 50dp
[content]
[content]
[content]
[content]    something like a ViewGroup with a ListView in it
[content]
[content]
[content]
[footer]     a ViewGroup that contains an EditText and Buttons

我已经尝试了各种不同的布局设置,但不能得到它的权利。无论是页脚占据了所有的空间,或内容涵盖了注脚。

I've tried all sorts of different layout settings, but can't get it right. Either the footer takes up all the space, or the content covers the footer.

下面是我到目前为止有:

Here's what I have so far:

<LinearLayout ...>

    <!-- Slot to put Header fragment in -->
    <FrameLayout
        android:id="@+id/header"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <!-- Here's where the content goes. This is supposed to be a ListView
         inserted as a fragment -->
    <FrameLayout
        android:id="@+id/content"
        ... />

    <include
        android:id="@+id/footer"
        ... />

</LinearLayout>

我离开了 layout_width layout_height 值空的,因为我不知道是什么将它们设置为

I left out the layout_width and layout_height values empty, because I don't know what to set them to.

更新
起初,我以为这个问题是因为我的的EditText 设置为 MAXLINES = 5 TextMultiline ,但我想用硬codeD高度去除一切,但一个按钮,插入还是覆盖了一切。我也试着设置&LT;页脚下面=内容&GT; 内容只覆盖页脚

UPDATES Initially, I thought the problem was because my EditText was set to maxLines=5 and TextMultiline, but I tried removing everything but one button with a hardcoded height, and the insert still covered everything. I also tried setting <footer below="content"> but then content just covered footer

推荐答案

的问题是,页脚布局包含另一个 RelativeLayout的。在页脚布局包括设置 layout_alignParentBottom =真的元素,这让页脚布局占据整个屏幕。我不知道为什么它会做到这一点,但是这是发生了什么。

The problem was that the footer layout included is another RelativeLayout. The footer layout contains elements that set layout_alignParentBottom="true", which made the footer layout take up the entire screen. I have no idea why it would do that, but that's what happens.

这篇关于与2调整视图创建一个Android布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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