Android聊天背景功能实现

解决输入法弹出时背景被顶上去或者挤压变形的问题

先看效果图:


Screenshot_1510219375.png
Screenshot_1510219378.png

实现方案:

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>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 175,929评论 25 709
  • 不知不觉,岁寒输入法的更新历史已经可以列出这么一长串来了。从中可以看出,岁寒的发展过程也是一个不断试错的过程,其中...
    临岁之寒阅读 34,534评论 1 6
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 14,372评论 4 61
  • 我羡慕你是自由的 和风一起远行 没有方向 没有归期 等待你的是一场未知的梦 我羡慕你是有梦的 和希望一同生长 没有...
    青微潇潇阅读 3,134评论 2 0
  • 梦想加努力=成功 标签: 梦想 努力 成功 2010-06-22 17:42 阅读(25)评论(1)编辑删除 ...
    田园牧歌123阅读 2,047评论 0 0

友情链接更多精彩内容