rokkonet

PC・Androidソフトウェア・アプリの開発・使い方に関するメモ

Viewに外枠を付ける android開発

2020 Jan. 04.

res/drawable/フォルダ内に設定xmlファイルを任意のファイル名MY_FILE.xmlで置く。

layoutファルダ内の当該Viewの記述部に android:background="@drawable/MY_FILE" と記述して読み込む。


res/drawable/MY_FILE.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<!-- 外枠 -->
<stroke android:width="3px" android:color="#CCCCCC" /> 

<!-- 背景色 -->
<solid android:color="#ffffff" /> 

<!-- 角の丸み -->
<corners android:radius="6dp" />
</shape>

layout/activity_main.xml

<EditText
    android:id="@+id/editTextMy"
    android:background="@drawable/MY_FILE"
 />