0

I'm making a chat Activity that has a send message box at the bottom. The send message box should always be visible and always be at the bottom of the screen. The Scrollview has a vertical LinearLayout that has views added to it inside of a loop. It works pretty much perfectly except when the there are enough views in the LinearLayout to make it scrollable the last element is always covered by the send message box. If I make the send message box invisible you can see all of the views in the layout. See images for clarity.

I DO NOT WANT TO USE A ListView because I don't want to have to use an adapter

This image on the left shows the last item being covered. Then making the send message invisible shows the last element.

enter image description here enter image description here

Here's the layout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:showIn="@layout/activity_chat" tools:context="com.example.brian.cleverrent.ChatActivity">


    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fillViewport="true"
        android:id="@+id/scrollView" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:id="@+id/chatTimeLineLayout">

        </LinearLayout>
    </ScrollView>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/sendMessageLayout"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        android:background="#eeeeee"
        android:orientation="horizontal">

        <EditText
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/chatEditText"
            android:layout_weight=".9"/>

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Send"
            android:id="@+id/chatSendButton"
            android:layout_weight=".1"/>

    </LinearLayout>
</RelativeLayout>
bkapVT
  • 233
  • 1
  • 3
  • 10

2 Answers2

4

Maybe you could try using

android:fillViewport="true"

for the ScrollView. Haven't tested it myself, but it was proposed as a solution to a similar problem here LinearLayout not expanding inside a ScrollView.

Community
  • 1
  • 1
gabrielkerekes
  • 468
  • 4
  • 10
  • Using a combination of your answer and adding padding to the bottom of the scrollview fixed the problem – bkapVT Apr 28 '16 at 20:13
1

Solution was to add...

android:fillViewport="true"
android:paddingBottom="50dp"

Thanks to Nestel for answer

bkapVT
  • 233
  • 1
  • 3
  • 10