From 9dfe89ba6bdbfd4214dc89e76c7d58b072337d97 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 22 Mar 2016 19:16:02 +0100 Subject: [PATCH] add ripple effect --- .../gallery/MyRelativeLayout.java | 46 ------------------- app/src/main/res/drawable-v21/selector.xml | 17 +++++++ app/src/main/res/layout/directory_item.xml | 19 +++++--- app/src/main/res/values/colors.xml | 4 +- 4 files changed, 31 insertions(+), 55 deletions(-) delete mode 100644 app/src/main/java/com/simplemobiletools/gallery/MyRelativeLayout.java create mode 100644 app/src/main/res/drawable-v21/selector.xml diff --git a/app/src/main/java/com/simplemobiletools/gallery/MyRelativeLayout.java b/app/src/main/java/com/simplemobiletools/gallery/MyRelativeLayout.java deleted file mode 100644 index 032571b66..000000000 --- a/app/src/main/java/com/simplemobiletools/gallery/MyRelativeLayout.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.simplemobiletools.gallery; - -import android.content.Context; -import android.graphics.Canvas; -import android.graphics.drawable.Drawable; -import android.util.AttributeSet; -import android.widget.RelativeLayout; - -public class MyRelativeLayout extends RelativeLayout { - private Drawable mForegroundSelector; - - public MyRelativeLayout(Context context) { - super(context); - } - - public MyRelativeLayout(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public MyRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - } - - { - mForegroundSelector = getResources().getDrawable(R.drawable.selector); - } - - @Override - protected void drawableStateChanged() { - super.drawableStateChanged(); - mForegroundSelector.setState(getDrawableState()); - invalidate(); - } - - @Override - protected void onSizeChanged(int w, int h, int oldw, int oldh) { - super.onSizeChanged(w, h, oldw, oldh); - mForegroundSelector.setBounds(0, 0, w, h); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - mForegroundSelector.draw(canvas); - } -} diff --git a/app/src/main/res/drawable-v21/selector.xml b/app/src/main/res/drawable-v21/selector.xml new file mode 100644 index 000000000..4d61c7b4d --- /dev/null +++ b/app/src/main/res/drawable-v21/selector.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/directory_item.xml b/app/src/main/res/layout/directory_item.xml index 7fd09d4f0..34d7edc6d 100644 --- a/app/src/main/res/layout/directory_item.xml +++ b/app/src/main/res/layout/directory_item.xml @@ -1,14 +1,19 @@ - + android:layout_height="match_parent"> - + android:layout_height="match_parent" + android:foreground="@drawable/selector"> + + + - + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 05cca9d69..f7af5d55d 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -5,6 +5,6 @@ #FF4081 #ff222222 #66000000 - #11000000 - #44000000 + #33000000 + #66000000