RecyclerView占用屏幕空间全部 [英] RecyclerView takes up all screenspace

查看:287
本文介绍了RecyclerView占用屏幕空间全部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个RecyclerView一些麻烦,在布局文件

So I'm having some trouble with a RecyclerView in a layout file

这是:

<android.support.v7.widget.RecyclerView
    android:id="@+id/chat_listview"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingRight="@dimen/abc_action_bar_default_padding_material"
    android:paddingLeft="@dimen/abc_action_bar_default_padding_material"
    />


<LinearLayout
    android:layout_below="@id/chat_listview"
    android:layout_width="match_parent"
    android:layout_height="@dimen/bottom_bar_height"
    android:orientation="horizontal"
    >

    <EditText
        android:id="@+id/chat_input_edittext"
        android:layout_weight="7"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:inputType="textAutoCorrect"
        />

    <Button
        android:id="@+id/chat_send_button"
        android:layout_weight="1"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:background="@drawable/ic_action_send_now"
        />

    </LinearLayout>

     

该RecyclerView是可见的,滚动的,但的LinearLayout和视图里面是不可见的。我尝试了不少东西,但没有什么迄今为止的工作。

The RecyclerView is visible and scrollable but the LinearLayout and the Views inside are not visible... I tried quite a few things but nothing has worked so far.

可以在任何你请点我到正确的方向?

Can any of you please point me into the right direction?

提前感谢!

推荐答案

更​​改根视图到的FrameLayout。中的LinearLayout的严重性设置为底部

Change the root view to a FrameLayout. Set the gravity of the LinearLayout to bottom

<FrameLayout 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.support.v7.widget.RecyclerView
    android:id="@+id/chat_listview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingRight="@dimen/abc_action_bar_default_padding_material"
    android:paddingLeft="@dimen/abc_action_bar_default_padding_material"
/>


<LinearLayout
    android:layout_below="@id/chat_listview"
    android:layout_width="match_parent"
    android:layout_height="@dimen/bottom_bar_height"
    android:layout_gravity="bottom"
    android:orientation="horizontal">

    <EditText
        android:id="@+id/chat_input_edittext"
        android:layout_weight="7"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:inputType="textAutoCorrect"/>

    <Button
        android:id="@+id/chat_send_button"
        android:layout_weight="1"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:background="@drawable/ic_action_send_now"/>

    </LinearLayout>
</FrameLayout>

另外,你可以用一个的FrameLayout线性布局 并将其设置为align_parentBottom = true,如果它是一个相对布局或根的线性布局,你还有其他的事情在您的视图。

Alternatively, you can wrap the linear layout in a FrameLayout and set it to align_parentBottom = true if it is a relative layout or a linear layout at your root and you have other things in your view.

这篇关于RecyclerView占用屏幕空间全部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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