0

I am coding a chat application for android. It's styled like a normal chat but also has a video form in the top screen area. The messages scrollview list should start after the video element, instead of top screen. I've been trying to add it but it's messing up my existing layout. I'm still learning how to handle xml styling so I hope to learn the correct way on this website.

Here is my current layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_main_relative_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageButton
    android:id="@+id/fullscreen_button"
    android:layout_width="40dp"
    android:layout_height="40dp"
    android:layout_marginStart="16dp"
    android:layout_marginTop="16dp"
    android:layout_marginEnd="16dp"
    android:layout_marginBottom="16dp"
    android:background="@null"
    android:scaleType="fitCenter"
    android:src="@drawable/fullscreen"
    android:layout_alignParentEnd="true" />

<com.example.virtualavatarchat.VideoSurfaceView
    android:id="@+id/activity_crop_video_surface_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="false"
    android:layout_marginTop="16dp" />

<LinearLayout
    android:id="@+id/layout_chat"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:gravity="bottom"
    android:layout_alignParentBottom="true">

    <EditText
        android:id="@+id/edit_text_message"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:hint="Type your message here"/>

    <Button
        android:id="@+id/button_send"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Send"/>

</LinearLayout>

ScrollView to add:

<ScrollView
android:id="@+id/message_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:fillViewport="true"
android:scrollbars="vertical">

<LinearLayout
    android:id="@+id/message_list"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
    
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Hello, world!"/>
    
</LinearLayout>

Layout with no scrollview added: https://i.stack.imgur.com/IhlCX.jpg

Thanks in advance!

I tried adding the ScrollView under the video view but it doesn't appear. I tried a combination of Grid layout, changing heights, etc. but with no success. I was expecting the scrollview to display messages under the video area.

Mattia
  • 11
  • 2
  • You can use the Nested Scrollview https://stackoverflow.com/questions/34773982/android-scrollview-vs-nestedscrollview – user2357113 Mar 27 '23 at 07:51

1 Answers1

0

Instead of using scrollview you can use recyclerview to show the messages. So it will be easy to update the list when new message comes.With scroll view you might need to add new textview whenever message list updated.So better go with recyclerview.And you can use a constraint layout to position each item.