Android: Relative layout content goes below screen

Neo

I'm new to android and I'm just trying to create a chat client. However the content at the bottom just goes off-screen.

The layout files:

chat_layout.xml

<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:background="#e1e1e1"
android:orientation="vertical" >

<LinearLayout
    android:id="@+id/form"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentStart="true"
    android:background="#91f1f1f1"
    android:orientation="horizontal"
    android:paddingBottom="2dp" >

    <ImageButton
        android:id="@+id/sendMessageButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:background="@drawable/send_button"
        android:text="d" />
</LinearLayout>


</RelativeLayout>

activity_mail.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.marothiatechs.mchat.MainActivity">

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingTop="@dimen/appbar_padding_top"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|enterAlways"
        app:popupTheme="@style/AppTheme.PopupOverlay">

    </android.support.v7.widget.Toolbar>

    <android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</android.support.design.widget.AppBarLayout>

<android.support.v4.view.ViewPager
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />


</android.support.design.widget.CoordinatorLayout>

This looks good in preview window of Android Studio. Android Studio Preview

However, on my device the image button is not visible. Actual device

But when I increase the "paddingBottom" of linearlayout to say "200dp", the button becomes visible.Actual device - Bottom padding at 200dp

I found similar questions on SO, and most of them suggest using ScrollView. But I don't think ScrollView is necessary in my case. Any ideas?

Sabari

Try this-

Use AppBarLayout and ViewPager inside a LinearLayout.

  <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.marothiatechs.mchat.MainActivity">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingTop="@dimen/appbar_padding_top"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|enterAlways"
        app:popupTheme="@style/AppTheme.PopupOverlay">

    </android.support.v7.widget.Toolbar>

    <android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</android.support.design.widget.AppBarLayout>

<android.support.v4.view.ViewPager
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</LinearLayout>

</android.support.design.widget.CoordinatorLayout>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Android place Relative Layout below Relative Layout programmatically

From Dev

Android place Relative Layout below Relative Layout programmatically

From Dev

Split layout for HTML screen, content below not visible

From Dev

Android: creating a layout that goes beyond screen width

From Dev

Content goes off screen in Android 4.1.1

From Dev

Android: 2 relative layout divided in half screen

From Dev

Android: Box that fills entire screen with content below

From Dev

Android relative layout, right align a textview below another textview

From Dev

Android Layout- Part of TextView goes off edge of screen

From Dev

how to set each layout below another layout inside relative layout in android

From Dev

how to set each layout below another layout inside relative layout in android

From Dev

Android make button 1/3 of screen width and height in relative layout

From Dev

Android layout - set rounded corner radius relative to screen size

From Dev

Android layout - set rounded corner radius relative to screen size

From Dev

Relative layout: layout_below a CenterVertical element

From Dev

Navigation Drawer Options goes below the layout

From Dev

How to make every content of a Relative Layout clickable in android

From Dev

Content goes below the button when the height is adjusted

From Dev

Content goes below the button when the height is adjusted

From Dev

relative layout not fitting the entire screen

From Dev

Place a button in Relative layout below the custom zoomview

From Dev

Zooming a layout (Relative Layout) in android

From Dev

Zooming a layout (Relative Layout) in android

From Dev

Android Layout Below and Above

From Dev

Full screen div with content below it in

From Dev

android relative layout design

From Dev

Infalting Relative Layout Android

From Dev

Relative layout android loopable

From Dev

Android relative layout issue

Related Related

  1. 1

    Android place Relative Layout below Relative Layout programmatically

  2. 2

    Android place Relative Layout below Relative Layout programmatically

  3. 3

    Split layout for HTML screen, content below not visible

  4. 4

    Android: creating a layout that goes beyond screen width

  5. 5

    Content goes off screen in Android 4.1.1

  6. 6

    Android: 2 relative layout divided in half screen

  7. 7

    Android: Box that fills entire screen with content below

  8. 8

    Android relative layout, right align a textview below another textview

  9. 9

    Android Layout- Part of TextView goes off edge of screen

  10. 10

    how to set each layout below another layout inside relative layout in android

  11. 11

    how to set each layout below another layout inside relative layout in android

  12. 12

    Android make button 1/3 of screen width and height in relative layout

  13. 13

    Android layout - set rounded corner radius relative to screen size

  14. 14

    Android layout - set rounded corner radius relative to screen size

  15. 15

    Relative layout: layout_below a CenterVertical element

  16. 16

    Navigation Drawer Options goes below the layout

  17. 17

    How to make every content of a Relative Layout clickable in android

  18. 18

    Content goes below the button when the height is adjusted

  19. 19

    Content goes below the button when the height is adjusted

  20. 20

    relative layout not fitting the entire screen

  21. 21

    Place a button in Relative layout below the custom zoomview

  22. 22

    Zooming a layout (Relative Layout) in android

  23. 23

    Zooming a layout (Relative Layout) in android

  24. 24

    Android Layout Below and Above

  25. 25

    Full screen div with content below it in

  26. 26

    android relative layout design

  27. 27

    Infalting Relative Layout Android

  28. 28

    Relative layout android loopable

  29. 29

    Android relative layout issue

HotTag

Archive