/ChatImageView

app聊天界面里常见的气泡图片效果

Primary LanguageJava

ChatImageView

一个实现图片气泡效果的自定义View

使用

gradle

Step 1. Add the JitPack repository to your build file

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

Step 2. Add the dependency

dependencies {
    compile 'com.github.nyakokishi:ChatImageView:1.0.2'
}

xml配置

使用.9.png时需指定app:ninePNG属性,此时图片的气泡效果由xfermode实现

<io.github.leibnik.chatimageview.ChatImageView
        xmlns:app="http://schemas.android.com/apk/res-auto"
        app:ninePNG="@drawable/ppp"
        android:layout_width="200dp"
        android:layout_height="150dp"/>

不使用.9.png时,图片的气泡效果由BitmapShaderPath实现

<io.github.leibnik.chatimageview.ChatImageView
        xmlns:app="http://schemas.android.com/apk/res-auto"
        app:direction="left"
        app:arrow_height="15dp"
        app:arrow_width="15dp"
        app:arrow_top="15dp"
        app:offset="7dp"
        app:radius="7dp"
        android:layout_width="200dp"
        android:layout_height="150dp"/>
  • app:direction:箭头朝向,默认朝向左
  • app:arrow_height:箭头高度
  • app:arrow_width:箭头宽度
  • app:arrow_top:箭头距view顶边距离
  • app:offset:箭头偏移量
  • app:radius:圆角半径

下图可以清晰看出各个属性的含义

效果图

License

Apache 2.0 License