Android聊天背景功能實(shí)現(xiàn)

解決輸入法彈出時(shí)背景被頂上去或者擠壓變形的問題

先看效果圖:


Screenshot_1510219375.png
Screenshot_1510219378.png

實(shí)現(xiàn)方案:

package com.qiangqiang.chatback.views;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ScrollView;

/**
 * Created by qiangqiang on 2017/7/17 0017.
 */

public class NoScrollView extends ScrollView {
    public NoScrollView(Context context) {
        super(context);
    }

    public NoScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public NoScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        return true;
    }
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.qiangqiang.chatback.views.NoScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ImageView
            android:id="@+id/img_back"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@mipmap/bg"
            android:scaleType="centerCrop" />
    </com.qiangqiang.chatback.views.NoScrollView>

    <EditText
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true"
        android:hint="輸入你想輸入的文字" />

</RelativeLayout>
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Android 自定義View的各種姿勢1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 178,946評(píng)論 25 709
  • 不知不覺,歲寒輸入法的更新歷史已經(jīng)可以列出這么一長串來了。從中可以看出,歲寒的發(fā)展過程也是一個(gè)不斷試錯(cuò)的過程,其中...
    臨歲之寒閱讀 34,849評(píng)論 1 6
  • 發(fā)現(xiàn) 關(guān)注 消息 iOS 第三方庫、插件、知名博客總結(jié) 作者大灰狼的小綿羊哥哥關(guān)注 2017.06.26 09:4...
    肇東周閱讀 15,195評(píng)論 4 61
  • 我羨慕你是自由的 和風(fēng)一起遠(yuǎn)行 沒有方向 沒有歸期 等待你的是一場未知的夢 我羨慕你是有夢的 和希望一同生長 沒有...
    青微瀟瀟閱讀 481評(píng)論 2 0
  • 夢想加努力=成功 標(biāo)簽: 夢想 努力 成功 2010-06-22 17:42 閱讀(25)評(píng)論(1)編輯刪除 ...
    田園牧歌123閱讀 328評(píng)論 0 0

友情鏈接更多精彩內(nèi)容