浜松のWEBシステム開発・スマートフォンアプリ開発・RTK-GNSS関連の開発はお任せください
株式会社シーポイントラボ
TEL:053-543-9889
営業時間:9:00~18:00(月〜金)
住所:静岡県浜松市中区富塚町1933-1 佐鳴湖パークタウンサウス2F

【androidjava】view同士を合成して漫画チックな吹き出しを作る

imageviewで吹き出しを作るには、角っちょの角度を変えていく事で

作ることができますがこれだけだとちょい歪になりがち。

あるものだけで半端な吹き出しを作るよりも、真四角のviewを使うことで

それらしいモノが作れると聞いたのでさっそくchallengeしてみました。

LinearLayoutで囲ったRelativeLayoutで作業を行うのがポイント

 

</pre>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="250dp"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal">
<RelativeLayout
android:id="@+id/relativeLayout2"
android:layout_width="250dp"
android:layout_height="wrap_content"
tools:ignore="MissingConstraints">
<ImageView
android:id="@+id/whiteimage"
android:layout_width="250dp"
android:layout_height="88dp"
android:background="#fff"
tools:ignore="MissingConstraints" />
<View
android:layout_width="20dp"
android:layout_height="40dp"
android:layout_marginStart="110dp"
android:layout_marginTop="60dp"
android:background="#fff"
android:rotation="45" />
</RelativeLayout>
</LinearLayout>
<pre>

15行目のviewがその役割を担っています。

android:rotation=”45″でviewを傾けてImageViewに入れこむ

カタチを取っています。

実際の画像をこんな感じ。

 

 

これまで真ん中に吹き出しを作る方法がなくて困っていたのですが

文字と被らず綺麗に出来ました。

  • この記事いいね! (0)