2016-04-28 8 views
0

私は下部にメッセージを送信するチャットを行っています。メッセージの送信ボックスは常に表示され、常に画面の下部に表示する必要があります。 Scrollviewには、ループ内にビューが追加された垂直のLinearLayoutがあります。 LinearLayoutにスクロール可能にするのに十分なビューがある場合を除き、最後の要素は常にメッセージの送信ボックスでカバーされます。送信メッセージボックスを非表示にすると、レイアウト内のすべてのビューを見ることができます。明確にするために画像を参照してください。私は左のAndroid ChatActivity Bottom LinearLayoutはScrollViewのスクロール可能エリアの下部をカバーします

にこの画像をアダプターを使用する必要がありますする必要はありませんので、リストビューを使用したくない

は、最後の項目がカバーされて表示されます。次に、送信メッセージを非表示にすると、最後の要素が表示されます。

enter image description hereenter image description here

ここレイアウト

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:showIn="@layout/activity_chat" tools:context="com.example.brian.cleverrent.ChatActivity"> 


    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:fillViewport="true" 
     android:id="@+id/scrollView" > 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      android:id="@+id/chatTimeLineLayout"> 

     </LinearLayout> 
    </ScrollView> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/sendMessageLayout" 
     android:layout_centerHorizontal="true" 
     android:layout_alignParentBottom="true" 
     android:background="#eeeeee" 
     android:orientation="horizontal"> 

     <EditText 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/chatEditText" 
      android:layout_weight=".9"/> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Send" 
      android:id="@+id/chatSendButton" 
      android:layout_weight=".1"/> 

    </LinearLayout> 
</RelativeLayout> 

答えて

3

はたぶん、あなたはScrollViewのため

android:fillViewport="true" 

を使用して試みることができるのです。自分でテストしたことはありませんが、ここで同様の問題の解決策として提案されましたLinearLayout not expanding inside a ScrollView

+0

ためNestelへ

android:fillViewport="true" android:paddingBottom="50dp" 

のおかげでした – bkapVT

1

ソリューションは、あなたの答えの組み合わせを使用して問題を修正scrollviewの底にパディングを追加...追加するには答え

関連する問題