简体   繁体   English

为什么ListView不在相对布局内滚动

[英]Why listview is not Scroll inside Relative Layout

I am trying to scroll the list whose id is list.I try almost all the solution but noting work for me.I try to put the Relative layout inside the scroll view but it also not work for me.I also try to put the listview inside the scroll view but it also not work. 我正在尝试滚动其id为list的列表。我尝试了几乎所有解决方案,但对我而言却有用。我尝试将Relative布局放入滚动视图中,但对我也不起作用。我也尝试将listview在滚动视图中,但它也不起作用。

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/chat_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
<RelativeLayout
    android:id="@+id/head"
    android:background="@color/primary_dark"
    android:layout_width="fill_parent"
    android:layout_height="75dp">

    <TextView
        android:padding="15dp"
        android:id="@+id/grp_heading"
        android:textStyle="bold"
        android:textSize="18sp"
        android:textColor="@android:color/white"
        android:maxLines="1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</RelativeLayout>

<ListView
    android:layout_below="@+id/head"
    android:id="@+id/list"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:divider="@color/white"
    android:dividerHeight="@dimen/pad_5dp"
    android:fastScrollEnabled="true"
    android:paddingBottom="@dimen/pad_10dp"
    android:paddingTop="@dimen/pad_10dp"
    tools:listitem="@layout/chat_item_rcv" >
</ListView>
</RelativeLayout>
<com.github.ksoichiro.android.observablescrollview.ObservableListView
    android:id="@+id/list_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    />

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_marginBottom="32dp"
    android:layout_marginRight="32dp"
    android:src="@drawable/ic_add_white_24dp"
    app:borderWidth="0dp"
    app:fabSize="normal"
    app:rippleColor="@color/primary"
    />

     <com.example.covite.chat_layout.BottomSheetLayout
    android:id="@+id/bottom_sheet"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    app:ft_container_gravity="center"
    app:ft_color="@color/primary">

    <ListView
        android:id="@+id/list_menu"
        android:background="@color/primary"
        android:divider="@null"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

</com.valuevision.covite.chat_layout.BottomSheetLayout>
<LinearLayout
    android:id="@+id/send_message_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_gravity="bottom"
    android:background="#ffdddddd"
    android:gravity="center_vertical"
    android:orientation="horizontal">

    <ImageView
        android:id="@+id/iv_image"
        android:layout_width="40dp"
        android:layout_height="40dp"
        />

    <EditText
        android:id="@+id/message"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1" />

    <Button
        android:id="@+id/sendMessageButton"
        android:layout_width="48dp"
        android:layout_height="48dp"
        />

</LinearLayout>

You should try with 你应该尝试

I assume FrameLayout creating this problem. 我假设FrameLayout造成了这个问题。

  1. Use RelativeLayout instead of FrameLayout 使用RelativeLayout而不是FrameLayout

  2. Call ListView out side of RelativeLayout RelativeLayout外部调用ListView

Hope this helps . 希望这可以帮助 。

Change the layout height containing your listview to match_parent . 将包含listview的布局高度更改为match_parent

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

and your listview height to match_parent 和您的listview高度为match_parent

<ListView
    android:layout_below="@+id/head"
    android:id="@+id/list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

Also make sure that the list items you supply to the listview is long enough for you to scroll. 另外,请确保提供给listview的列表项足够长,以便您滚动。 Hope this helps. 希望这可以帮助。

EDIT: I am not sure what BottomSheetLayout is about, but try set its layout height to match_parent as well. 编辑:我不确定BottomSheetLayout是关于什么,但也尝试将其布局高度设置为match_parent。

<com.example.covite.chat_layout.BottomSheetLayout
    android:id="@+id/bottom_sheet"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="bottom"
    app:ft_container_gravity="center"
    app:ft_color="@color/primary">

OR if possible move your listview out of BottomSheetLayout , and make it a child for your RelativeLayout instead. 或者,如果可能,请将listview移出BottomSheetLayout ,并使其成为您的RelativeLayout的子级。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM