LoginSignup
30
26

More than 5 years have passed since last update.

枠線つきの吹き出しをAndroidでかんたんに作る

Posted at

BubbleLayout

BubbleLayout
枠線つきの吹き出しをAndroidでかんたんに作るライブラリを作成しました。

吹き出しを作れるViewのライブラリは、BubbleViewなど存在
したのですが、いい感じに枠線をつけれるのが存在しなかったので、作成してみました。

実装は地道にCanvasにPathを描画したのですが、その分軽量なライブラリになったと思います。

Dependencies

dependencies {
    compile 'com.daasuu:BubbleLayout:1.0.0'
}

Basic Usage


上記のレイアウトは下記のようにxmlで描画すれば非常に簡単に作成できます。

<com.daasuu.bl.BubbleLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="12dp"
    android:padding="8dp"
    app:bl_arrowDirection="right"
    app:bl_arrowHeight="8dp"
    app:bl_arrowPosition="16dp"
    app:bl_arrowWidth="8dp"
    app:bl_cornersRadius="6dp"
    app:bl_strokeWidth="1dp">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_marginRight="4dp"
        android:text="BubbleLayout"
        android:textColor="@android:color/holo_red_dark" />

</com.daasuu.bl.BubbleLayout>

Attributes

Attributesは下記の通りに用意しました。

attr description
bl_arrowWidth Width of the arrow, default 8dp
bl_arrowHeight Height of the arrow, default 8dp
bl_arrowPosition Position of the arrow, default 12dp
bl_cornersRadius Corner radius of the BubbleLayout, default 0dp
bl_bubbleColor Color of the BubbleLayout, default WHITE
bl_strokeWidth Width of the stroke, default 0dp
bl_strokeColor Color of the stroke, default GLAY
bl_arrowDirection Drawing position of the arrow : 'left' or 'top' or 'right' or 'bottom', default 'left'

是非、BubbleLayoutをご覧になり、Starもつけていただけると
とても嬉しく思います。pull reqestも大歓迎です!

30
26
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
30
26