リップルアニメーションのメモ
3043 ワード
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"/>
layout
<View
android:background="?android:attr/selectableItemBackground"/>
- 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"/>
src
val outValue = TypedValue()
getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true)
view.setBackgroundResource(outValue.resourceId)
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"/>
Author And Source
この問題について(リップルアニメーションのメモ), 我々は、より多くの情報をここで見つけました https://qiita.com/nakan-D128/items/7b22671dc72ef622779e著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .