gpt4 book ai didi

android - 超新星表情符号库与 Android 中的 socket.io 聊天应用程序集成

转载 作者:行者123 更新时间:2023-11-29 23:12:01 25 4
gpt4 key购买 nike

我正在通过 socket.io 在 android 中制作聊天应用程序,其中包括 recylerview/adapter 和模型类。我也成功地单独添加了表情符号库,但我想在同一 Activity 中添加表情符号库和 recyclerview。你能指导我如何在同一页面( Activity )上进行操作吗?答复将不胜感激。

我正在遵循这些指南。

https://github.com/hani-momanii/SuperNova-Emoji

https://dev.to/medaymentn/creating-a-realtime-chat-app-with-android--nodejs-and-socketio-4o55

最佳答案

Layout File for your Chat View

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/contentRoot1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorchatbg"
android:orientation="vertical">

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

<RelativeLayout
android:id="@+id/layout_header"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:layout_alignParentTop="true"
android:background="@color/voilacabs">

<RelativeLayout
android:id="@+id/layout_back_arrow"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingLeft="@dimen/margin_15"
android:paddingRight="@dimen/margin_15">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:src="@drawable/back_arrow" />

</RelativeLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/margin_10"
android:layout_toRightOf="@+id/layout_back_arrow"
android:gravity="center_vertical"
android:orientation="vertical">

<TextView
android:id="@+id/txt_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Username"
android:textColor="@color/white"
android:textSize="16dp" />


<TextView
android:id="@+id/txt_typing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Typing..."
android:textColor="@color/white"
android:textSize="16dp"
android:visibility="gone" />
</LinearLayout>


</RelativeLayout>

<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">

<android.support.v7.widget.RecyclerView
android:id="@+id/messageRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none" />

<View
android:layout_width="match_parent"
android:layout_height="4dp"
android:layout_gravity="bottom"
android:background="@drawable/shadow_top" />
</FrameLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="2dp">

<ImageView
android:id="@+id/buttonEmoji"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:padding="8dp"
android:src="@drawable/chat_smilly" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/buttonEmoji"
android:layout_weight="1">

<hani.momanii.supernova_emoji_library.Helper.EmojiconEditText
android:id="@+id/editTextMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:emojiconSize="28sp" />

</LinearLayout>

<LinearLayout
android:id="@+id/lauout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@+id/editTextMessage"
android:orientation="horizontal">

<ImageView
android:id="@+id/buttonMessage"
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="8dp"
android:src="@drawable/chat_send" />
</LinearLayout>


</LinearLayout>

</LinearLayout>




</LinearLayout>


</android.support.design.widget.CoordinatorLayout>

Your Activity Code is like

private EmojIconActions emojIcon;

edMessage = (EmojiconEditText) findViewById(R.id.editTextMessage);
btEmoji = (ImageView) findViewById(R.id.buttonEmoji);

emojIcon = new EmojIconActions(this, contentRoot, edMessage, btEmoji);
emojIcon.ShowEmojIcon();

关于android - 超新星表情符号库与 Android 中的 socket.io 聊天应用程序集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55914818/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com