ご覧いただきありがとうございます。チャットアプリケーションを作成しています。ほとんどの場合機能します。私が問題にしているのはスクロールだけです。EditTextを使用して、サーバーからの新しいメッセージを公開します。
方法による
msg = msg + "\n" + newMsg
EditText.setText(msg)
古いテキストの下にある新しいテキストが表示されたらすぐに表示する必要があります。
したがって、ビューが更新されたらすぐに下に自動スクロールするのが最善の方法だと思います。
それを行う簡単な方法はありますか?多分レイアウトのように?
再度、感謝します!
レイアウトのコード
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:id="@+id/sendButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="send"
/>
<EditText
android:id="@+id/msgBox"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="@+id/sendButton"
android:gravity="left"
android:longClickable="false"
/>
<EditText
android:id="@+id/chatBox"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:editable="false"
android:layout_above="@+id/msgBox"
android:scrollbars="vertical"
android:gravity="left|top"
android:isScrollContainer="true"
android:cursorVisible="false"
android:longClickable="false"
android:clickable="false"
android:autoLink="all"
/>
</RelativeLayout>