Reputation: 23883
My EditText and ImageButton not appear because of wrong positioning. Fragment successfully show up.
Here is my layout view code
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#e1e1e1"
android:orientation="vertical" >
<ListView
android:id="@+id/msgListView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/form"
android:divider="@null"
android:dividerHeight="0dp"
android:paddingBottom="10dp"
android:text="Hello World" />
<LinearLayout
android:id="@+id/form"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#91f1f1f1"
android:orientation="horizontal"
android:paddingBottom="2dp" >
<EditText
android:id="@+id/messageEditText"
android:layout_width="252dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignTop="@+id/button1"
android:layout_toLeftOf="@+id/sendMessageButton"
android:layout_weight="0.72"
android:ems="10"
android:maxHeight="80dp" />
<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>
My full source code is here https://github.com/IntellijSys/AndroidChat.
Upvotes: 0
Views: 96
Reputation: 23883
I already fixed it using my solution.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal"
android:background="#e1e1e1"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView android:id="@+id/msgListView"
android:paddingBottom="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:divider="@null"
android:dividerHeight="0dp"
android:text="+@string/hello_world"
android:layout_above="@+id/form" />
<LinearLayout
android:orientation="horizontal"
android:id="@+id/form"
android:background="#91f1f1f1"
android:paddingBottom="2dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true">
<EditText android:id="@+id/messageEditText"
android:layout_width="252dp"
android:layout_height="wrap_content"
android:maxHeight="80dp"
android:ems="10"
android:layout_weight="0.72"
android:layout_toLeftOf="@+id/sendMessageButton"
android:layout_alignTop="@+id/sendMessageButton"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true" />
<ImageButton android:id="@+id/sendMessageButton"
android:background="@drawable/send_button"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true" />
</LinearLayout>
</RelativeLayout>
Upvotes: 0
Reputation: 257
There is no issue in chat_layout.xml ,Your EditText and ImageButton is hiding because of the AppBarLayout .
You have used app:layout_behavior="@string/appbar_scrolling_view_behavior"
in ViewPager ,this is why your Bottom part if ChatFragment is not visible for first time,try to drag your tablayout upside .
Upvotes: 0
Reputation: 2847
<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="@drawable/bg_messages"
android:orientation="vertical"
tools:context=".MainFragment">
<ListView
android:id="@+id/msgListView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:orientation="horizontal"
android:gravity="center_vertical">
<EditText
android:id="@+id/message_input"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="@string/prompt_message"
android:imeActionId="@+id/send"
android:imeActionLabel="@string/action_send"
android:imeOptions="actionSend"
android:inputType="text"
android:maxLines="1"
android:singleLine="true"/>
<ImageButton
android:id="@+id/send_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/ic_menu_send"
android:contentDescription="@string/action_send"/>
</LinearLayout>
</LinearLayout>
you can use your listView at the place of RecycleView
Upvotes: 1
Reputation: 2182
Change Position of Listview like your linear layout is behind listview
<?xml version="1.0" encoding="utf-8"?>
<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:orientation="vertical">
<LinearLayout
android:id="@+id/form"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#91f1f1f1"
android:orientation="horizontal"
android:paddingBottom="2dp" >
<EditText
android:id="@+id/messageEditText"
android:layout_width="252dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignTop="@+id/button1"
android:layout_toLeftOf="@+id/sendMessageButton"
android:layout_weight="0.72"
android:ems="10"
android:maxHeight="80dp" />
<ImageButton
android:id="@+id/sendMessageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="d" />
</LinearLayout>
<ListView
android:id="@+id/msgListView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/form"
android:divider="@null"
android:dividerHeight="0dp"
android:paddingBottom="10dp"
android:text="Hello World" />
</RelativeLayout>
Upvotes: 0