Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加聊天背景的问题 #2

Closed
star3136 opened this issue Dec 29, 2015 · 11 comments
Closed

添加聊天背景的问题 #2

star3136 opened this issue Dec 29, 2015 · 11 comments
Assignees
Labels

Comments

@star3136
Copy link

如果需要添加聊天背景图片,背景图片就会被压扁了。

@Jacksgong
Copy link
Owner

好的,我今晚看下。

@Jacksgong
Copy link
Owner

这个并不是这个library的问题,不过根据你的需求,可以通过以下方法解决:

参考demo中的activity_chatting.xml(JKeyboardPanelSwitch/app/src/main/res/layout/activity_chatting.xml)做以下修改:

<cn.dreamtobe.kpswitch.widget.CustomRootLayout     xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

<!-- 修改 从这里开始 -->
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1.0">

<!-- 内嵌一个与RecyclerView/ListView同层级,scaleType是matrix的ImageView -->
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="matrix"
            android:src="@drawable/chatting_background" />

        <android.support.v7.widget.RecyclerView
            android:id="@+id/content_ryv"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </FrameLayout>
<!-- 修改结束 -->
    <LinearLayout
        android:id="@+id/sendMsgLayout"
        android:layout_width="fill_parent"
        android:layout_height="55dp"
        android:background="#fefefe"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:gravity="center_vertical"
        android:orientation="horizontal">
   ...

@Jacksgong Jacksgong self-assigned this Dec 29, 2015
@Jacksgong
Copy link
Owner

希望对你有所帮助。

@Jacksgong Jacksgong reopened this Dec 29, 2015
@star3136
Copy link
Author

万分感谢,没想到可以这么优雅的解决,之前我的做法是重新设置整个布局的高度,然后也重新布局输入框,把输入框放在软键盘的上面,但是这样就会有闪动的问题。这个方法给了我新的启发,谢谢了!

@Jacksgong
Copy link
Owner

恩恩。不用谢
但是不应该会引起闪动布局的,不知道你是遇到了什么问题。这是根据demo中的activity_chatting.xml(JKeyboardPanelSwitch/app/src/main/res/layout/activity_chatting.xml)布局修改后的完整xml内容,你替换进去看看。

<?xml version="1.0" encoding="utf-8"?>
<cn.dreamtobe.kpswitch.widget.CustomRootLayout     xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">


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

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="matrix"
            android:src="@drawable/chatting_background" />

        <android.support.v7.widget.RecyclerView
            android:id="@+id/content_ryv"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </FrameLayout>

    <LinearLayout
        android:id="@+id/sendMsgLayout"
        android:layout_width="fill_parent"
        android:layout_height="55dp"
        android:background="#fefefe"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:gravity="center_vertical"
        android:orientation="horizontal">

        <ImageView
            android:id="@+id/voice_text_switch_iv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:adjustViewBounds="true"
            android:src="@drawable/chatting_voice_btn_icon" />

        <RelativeLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="8dp"
            android:layout_marginTop="5dp"
            android:layout_weight="1.0">


            <EditText
                android:id="@+id/send_edt"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/chattting_edit_bg"
                android:gravity="center_vertical|left"
                android:minHeight="38dp"
                android:padding="5dp"
                android:textColor="@android:color/black"
                android:textSize="14sp"
                android:visibility="visible" />


            <TextView
                android:id="@+id/send_voice_btn"
                android:layout_width="fill_parent"
                android:layout_height="38dp"
                android:background="@drawable/chatting_voice_bg"
                android:clickable="true"
                android:gravity="center"
                android:soundEffectsEnabled="true"
                android:text="@string/press_say"
                android:textColor="#b3b3b3"
                android:textSize="16sp"
                android:visibility="gone" />
        </RelativeLayout>

        <RelativeLayout
            android:layout_width="60dp"
            android:layout_height="match_parent">

            <ImageView
                android:id="@+id/plus_iv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:adjustViewBounds="true"
                android:clickable="true"
                android:onClick="onClickPlusIv"
                android:src="@drawable/chatting_plus_btn_icon"
                android:visibility="visible" />

            <TextView
                android:id="@+id/send_btn"
                android:layout_width="50dp"
                android:layout_height="34dp"
                android:layout_centerInParent="true"
                android:background="@drawable/chatting_send_bg"
                android:clickable="true"
                android:gravity="center"
                android:text="@string/press_say"
                android:textColor="@android:color/white"
                android:textSize="14sp"
                android:visibility="gone" />

        </RelativeLayout>
    </LinearLayout>

    <cn.dreamtobe.kpswitch.widget.PanelLayout
        android:id="@+id/panel_root"
        android:layout_width="fill_parent"
        android:layout_height="@dimen/panel_height"
        android:background="#fffefefe"
        android:orientation="vertical"
        android:visibility="gone">

        <View
            android:layout_width="match_parent"
            android:layout_height="1px"
            android:background="#d5d3d5" />

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:padding="10dp">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:clickable="true"
                android:gravity="center"
                android:onClick="onClickPhoto"
                android:orientation="vertical"
                android:padding="10dp">

                <ImageView
                    android:id="@+id/send_img_iv"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/chatting_pic_icon" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingTop="3dp"
                    android:text="@string/picture"
                    android:textColor="#b3b3b3"
                    android:textSize="14sp" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:orientation="vertical"
                android:padding="10dp">

                <ImageView
                    android:id="@+id/send_site_iv"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/chatting_site_icon" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingTop="3dp"
                    android:text="@string/site"
                    android:textColor="#b3b3b3"
                    android:textSize="14sp" />

            </LinearLayout>
        </LinearLayout>
    </cn.dreamtobe.kpswitch.widget.PanelLayout>

</cn.dreamtobe.kpswitch.widget.CustomRootLayout>

@star3136
Copy link
Author

谢谢解答了,最近项目比较忙,没有及时回复,抱歉。
还有一个问题,在模拟器(genymotion)里还是有闪动,不是必现,一直点+图标就会偶尔出现,真机还没有发现。

@Jacksgong
Copy link
Owner

恩。没有关系。
十分抱歉,我很久没有用模拟器了。我抽空也看看genymotion上面为什么会有问题。真机有几款应用在用这套架构,目前还没有反馈有什么问题。

@star3136
Copy link
Author

这个挺完美的,我之前搜索资料写的一个,在遇到背景压扁问题的时候重新设置了整个布局的高度,造成了panel闪动。

@Jacksgong
Copy link
Owner

恩。谢谢:)。如果还遇到什么问题,直接issue反馈,我会持续跟进的。也欢迎PR.

@Jacksgong
Copy link
Owner

我这边在genymotion的nexus5虚拟机上并没有你提到的问题,不知到有哪里遗漏的。我录制了视频:

genymotion-test

@tp19970424
Copy link

您好,我照着这个改了怎么背景还是被挤上去了,图片被挤成一团了,这个是怎么回事呢?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants