cre*_*ver 5 android android-recyclerview
我在片段中使用RecyclerView并将其高度设置为wrap_content并在其下方有一个按钮.但问题是RecyclerView占用了整个空间并且按钮不可见.出了什么问题?
这是我的xml文件 -
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:background="#fff"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/empty_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="17sp"
android:layout_marginTop="20dp"
android:visibility="gone"
android:text="You haven't added any names yet!"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/names_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"/>
<Button
android:id="@+id/add_name"
android:layout_width="203dp"
android:layout_height="wrap_content"
android:layout_below="@+id/recycler_view"
android:padding="15dp"
android:textColor="#F3F3F3"
android:textSize="17sp"/>
</LinearLayout>`
Run Code Online (Sandbox Code Playgroud)
Apu*_*rva 18
您应该设置weight为RecyclerView并更改height为0dp
<android.support.v7.widget.RecyclerView
android:id="@+id/names_list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:scrollbars="vertical"/>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4689 次 |
| 最近记录: |