#はじめに
テキストやボタンの端を丸くする方法を簡単にまとめました。
#1.Layout resource file の作成
layout_width 200dp
layout_height 50dpのTextViewの端を丸くさせます。
drawableフォルダにDrawable resource file
を作成する
#2.背景色と丸み
作成した、Drawable resource file
で<shape
タグにし
<solid android:color="@android:color/holo_orange_light"/>
で色を
<corners android:radius="25dp"/>
で丸の大きさを決める。
今回はtextviewのhightを50dpにしたので25dpとした。
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@android:color/holo_orange_light"/>
<corners android:radius="25dp"/>
</shape>
#3.backgrounに反映させる
TextView
のbackgroundを作成したDrawable resource file
に指定する。
<TextView
android:id="@+id/textView"
android:layout_width="200dp"
android:layout_height="50dp"
android:gravity="center"
android:text="TextView"
android:background="@drawable/rounded_textview"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
丸くする事が出来た!
![スクリーンショット 2020-04-26 21.50.45.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.ap-northeast-1.amazonaws.com%2F0%2F619313%2F5f9efce5-0ebb-68c3-56ba-ad9050afcaa4.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=5b7348d557fa1b8b07c539f2f25e6eb2)