2016-10-08 3 views
-2

저는 채팅 애플리케이션을 만듭니다. 대화방 활동에서 리사이클 뷰 항목이 텍스트 뷰 아래에 있습니다. 데이터 항목이 증가하면 텍스트보기.리사이클 러 뷰에서 데이터 항목이 증가 할 때 텍스트 뷰 아래에 리사이클러 뷰 데이터가 있습니다.

Below is the screenshot

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> 

나는 안드로이드 응용 프로그램에서 초보자입니다 때문에 내가 잘못 어딘지 알고 아닙니다, 당신은 변경해야 나에게

+0

당신의 item.xml을 게시하시기 바랍니다 .... item.xml에 약간의 변화가 item.xml, 난 당신을 얻을 did'nt – sushildlh

+0

이 필요합니다 .. –

답변

1

속성 id이 속성 android:layout_above="@+id/LLMain"를 사용하여 Recycler Viewandroid:id="@+id/LLMain" 같은 Linear Layout에 그것을 제공 .And도 Recyclerviewheightmatch parent을 제공합니다.

이 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"> 
0

먼저 도와주세요 RelativeLayout ~ LinearLayout (세로) 다음에 RecyclerView을 새로 넣고 linear_layout에 넣고 가면을 android:layout_weight="3"으로 설정합니다. 이 코드를 따라하면 원하는대로 작동합니다.

<!--<TextView--> 
<!--android:layout_width="wrap_content"--> 
<!--android:layout_height="wrap_content"--> 
<!--android:text="" --> 
<!--android:id="@+id/tvChat"/>--> 

    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/linearLayout4" 
     android:layout_weight="3" 
     android:splitMotionEvents="false"> 
     <android.support.v7.widget.RecyclerView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:id="@+id/rvCM" 
      app:stackFromEnd="true" /> 
    </LinearLayout> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:layout_alignParentBottom="true" 
     android:layout_marginTop="10dp" 
     android:layout_marginBottom="10dp" 
     android:padding="0dp" 
     android:gravity="center" 
     android:layout_weight="1" 
     android:splitMotionEvents="false"> 
     <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_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> 
    </LinearLayout> 
1

다음을 수행

,
1은 id 편집기를 포함 linear layout에 추가합니다.
2. recycler viewlayout height을 부모와 일치하도록 변경하십시오.
3. recyclerview

android:layout_above="@+id/editor_id" 

4에이 속성을 추가하고 편집기 linear layout

P.S.에서 weight sum 속성을 제거 이러한 경우의 LinearLayout에 부모 RelativeLayout의를 변경하는 몇 가지 장치에 미친 결과를 줄 수 있으므로 적절한 배치 위치와 RelativeLayout의를 사용하여 당신이 부여됩니다 할 필요 당신이 더 변경할 필요가 없습니다 생각

관련 문제