我正在学习Android编程和工作在一个简单的“职位”,“评论”,“喜欢”类型的应用程序。从未在一百万年内,我会认为构建Android应用程序最难的部分是试图让布局工作。我拥有来自Firebase数据库的所有信息,这很容易,但试图让布局看起来是正确的是几乎不可能的。我甚至尝试从他们的快速入门应用程序中复制/粘贴Firebase,这是一个执行数据库工作的应用程序。不过,它不会填满该区域。顶部部分看起来不错,但我有一个RecyclerView,应该重复该帖子的评论,它正在重复它们,但它只是页面高度的一小部分,正如您在截图中看到的那样。我曾尝试使用ScrollView,NestedScrollView,将RecyclerView放入RelativeLayout,LinearLayout中,没有任何工作。这里是XML的观点...RecyclerView没有填充在Android的其余空间
<?xml version="1.0" encoding="utf-8"?>
<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="com.google.firebase.quickstart.auth.PostDetailActivity">
<include
android:id="@+id/post_author_layout"
layout="@layout/include_post_author"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true" />
<include
android:id="@+id/post_text_layout"
layout="@layout/include_post_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/post_author_layout"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp" />
<LinearLayout
android:id="@+id/comment_form"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="@+id/post_text_layout"
android:layout_marginTop="20dp"
android:weightSum="1.0">
<EditText
android:id="@+id/field_comment_text"
android:layout_width="0dp"
android:layout_weight="0.8"
android:layout_height="wrap_content"
android:maxLines="1"
android:hint="Write a comment..."/>
<Button
android:id="@+id/button_post_comment"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="0dp"
android:layout_weight="0.2"
android:layout_height="wrap_content"
android:text="Post"/>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_comments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/comment_form"
tools:listitem="@layout/item_comment" />
</RelativeLayout>
退房的截图,评论部分是如此之小,我把截图中滚动所以你可以看到顶部是在正确的位置的中间,但底部只有几个像素高,它不会一直走到屏幕的底部。任何帮助是极大的赞赏。谢谢。
如果我将RecyclerView高度设置为match_parent,我仍然只会得到一个评论,因为每个评论现在都是父级的高度。
删除'android:paddingBottom'? –
是的,你可以在顶部的RelativeLayout中删除根目录下的填充 – cutiko
?我试过了,它只是“5dp”,所以它并没有太大的伤害 –