In my app, there is a tabbed activity with three fragments
. The first fragment has a form to create a new task, the second fragment has the list of all the saved tasks, and the third fragment will show the comments on a task when selected from the list in the second fragment. The third fragment
is also supposed to act like a chat activity which posts comments when you type them in and tap the send button. The XML layout of this third fragment
is as follows:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="@android:color/darker_gray"
android:orientation="vertical"
tools:context="com.example.ishita.assigntasks.CommentsFragment">
<TextView
android:id="@+id/frag_task_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#dd55ff"
android:padding="10dp" />
<ListView
android:id="@+id/frag_comment_list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:transcriptMode="normal" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@android:color/white">
<EditText
android:id="@+id/frag_msg_edit"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:layout_weight="1" />
<ImageButton
android:id="@+id/frag_send_btn"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:background="@android:color/background_light"
android:contentDescription="@string/send_btn"
android:src="@android:drawable/ic_menu_send" />
</LinearLayout>
</LinearLayout>
As you can see, there is a TextView
and a ListView
and below that is another LinearLayout
. Here is how it should look (the purple bar is the TextView
):
And here is how it actually looks:
The TextView
shows up above the ListView
, but the LinearLayout
does not. It is there, though. If I do android:layout_marginBottom="20dp"
on the outermost LinearLayout
, it does show up, but the ActionBar
scrolls up and overlaps with the notification bar so that the title on the ActionBar
and the notifications on the notification bar are both visible simultaneously and neither is legible.
I searched a lot and this seemed a common issue, but none of the solutions helped me. Believe me, I tried everything I could find. I tried wrapping the whole thing in a FrameLayout
, using a RelativeLayout
in place of the outermost LinearLayout
, using two LinearLayout
s--one to wrap the TextView
and the ListView
and the other to wrap the EditText
and the ImageButton
, etc., but nothing was able to show the bottom LinearLayout
below the ListView
. I even tried to set focus on the EditText
when the fragment launches so that the keyboard would show and I can type, but even that doesn't help.
Note: On the other hand, if I use the exact same layout on an activity
, the bottom LinearLayout
displays exactly as it should.
I am unable to find the bug. Please help!