【问题标题】:Supernova Emoji library integration with socket.io chat app in AndroidSupernova Emoji 库与 Android 中的 socket.io 聊天应用程序集成
【发布时间】:2019-04-30 06:04:22
【问题描述】:

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

我正在遵循这些指南。

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

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

【问题讨论】:

    标签: android android-recyclerview socket.io emoji


    【解决方案1】:

    聊天视图的布局文件

    <?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>
    

    你的活动代码是这样的

    private EmojIconActions emojIcon;
    
    edMessage = (EmojiconEditText) findViewById(R.id.editTextMessage);
    btEmoji = (ImageView) findViewById(R.id.buttonEmoji);
    
    emojIcon = new EmojIconActions(this, contentRoot, edMessage, btEmoji);
                    emojIcon.ShowEmojIcon();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-08-11
      • 1970-01-01
      • 2011-09-24
      • 1970-01-01
      • 2014-08-13
      • 1970-01-01
      • 2017-05-31
      • 1970-01-01
      相关资源
      最近更新 更多