LoginSignup
1
0

More than 5 years have passed since last update.

メモ:Android では view にボーダーをつけるのに style を作らなくてはいけない。

Last updated at Posted at 2018-12-13

個人的メモ。

iOS で view に border をつけるには

view.layer.borderColor = UIColor.black.cgColor
view.layer.borderWidth = 1

で、非常に簡単なのであるが、Android で view に Border をつけるには

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
   <solid android:color="@android:color/white" />
   <stroke android:width="1dip" 
           android:color="@android:color/black"/>
</shape>

みたいなスタイルを res/drawable 配下に作り (例えば border_rect.xml)、それを view の background に指定する。

<LinearLayout
    ...
    android:background="@drawable/border_rect"
    ...
/>

こういうのは、android:borderWidth/borderColor なんかを用意してくれればいいのにと思うなあ。

参照: https://stackoverflow.com/questions/3496269/how-do-i-put-a-border-around-an-android-textview

1
0
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
1
0