我正在创建一个聊天应用程序。在聊天室活动中,回收者视图项位于文本视图下。我的意思是,当数据项增加时,它位于文本视图下。
activty_chatroom.xml
<?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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.boosterfoxindia.foxindtracker.ChatRoomActivity">
<!--<TextView-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:text="" -->
<!--android:id="@+id/tvChat"/>-->
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/rvCM"
app:stackFromEnd="true"></android.support.v7.widget.RecyclerView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="7"
android:layout_alignParentBottom="true"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:padding="0dp"
android:gravity="center"
>
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/etMessage"
android:layout_weight="6"
android:background="@drawable/chattextbox"
android:padding="10dp"
android:hint="Enter message..."
android:elevation="2dp"
android:layout_gravity="center"
android:layout_marginTop="10dp"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/btnSend"
android:background="@drawable/circle"
android:orientation="vertical"
android:gravity="center"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="0dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@mipmap/ic_send_white_24dp"
android:layout_gravity="center"
android:padding="10dp"
/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
我是android应用程序的初学者,因此我不知道我在哪里错,请帮帮我
我觉得你并不需要做出更多的改变你需要做的就是给一个id
要Linear Layout
这样android:id="@+id/LLMain"
,它给Recycler View
使用这个属性android:layout_above="@+id/LLMain"
。而且也给height
match parent
到Recyclerview
。
像这样的XML。
<android.support.v7.widget.RecyclerView
android:id="@+id/rvCM"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/LLMain"
app:stackFromEnd="true" />
<LinearLayout
android:id="@+id/LLMain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal"
android:padding="0dp"
android:weightSum="7">
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句