LoginSignup
1
0

More than 3 years have passed since last update.

リップルアニメーションのメモ

Last updated at Posted at 2019-04-30

background

  • すべてのView(CardViewを除く)
layout
<View
    android:background="?android:attr/selectableItemBackground"/>

foreground

  • FrameLayout
  • CardView(FrameLayoutを継承しているため)
  • Android 6.0/APIレベル 23/Marshmallow以上のすべてのView
layout
<View
    android:foreground="?android:attr/selectableItemBackground"/>

コードで設定

src
val outValue = TypedValue()
getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true)
view.setBackgroundResource(outValue.resourceId)

カスタムのbackgroundにリップルアニメーションをつける

drawable/ripple.xml
<ripple xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- ここをカスタム -->
    <item android:drawable="@color/colorAccent"/>
</ripple>
layout
<View
    android:background="@drawable/ripple"/>
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