14
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AndroidのViewに角丸の枠線とRippleエフェクトを同時に適用させる

Last updated at Posted at 2017-04-26

こちらの記事に記載されている通りなのですが、
以下の Drawable Resource を追加し、対象のViewのbackgroundに適用することで実現できます。

<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="?android:attr/colorControlHighlight">
    <item android:id="@android:id/mask">
        <shape android:shape="rectangle">
            <solid android:color="#000000" />
            <corners android:radius="3dp" />
        </shape>
    </item>

    <item>
        <shape android:shape="rectangle">
            <!-- 枠線 width:線の幅、color:線の色 -->
            <stroke
                android:width="1dp"
                android:color="#4d000000" />

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

なおこれは v21 以降でしか使えませんのでご注意ください。

14
16
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
14
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?