2022-03-18
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に入れこむ
カタチを取っています。
実際の画像をこんな感じ。
これまで真ん中に吹き出しを作る方法がなくて困っていたのですが
文字と被らず綺麗に出来ました。