aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/github
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-12-18 17:46:26 -0800
committerScott Jackson <daneren2005@gmail.com>2015-12-18 17:46:26 -0800
commit2b96064830d46523c44247d368c51dc5a95f6a0f (patch)
treeff26972addfb032b3ff27ea37f1ac26e158bacf2 /app/src/main/java/github
parent8cff8360a9e463035cb7fb31c72b38c92af71030 (diff)
downloaddsub-2b96064830d46523c44247d368c51dc5a95f6a0f.tar.gz
dsub-2b96064830d46523c44247d368c51dc5a95f6a0f.tar.bz2
dsub-2b96064830d46523c44247d368c51dc5a95f6a0f.zip
Start of my own basic CardView since support version doesn't play nice with SquareImageView
Diffstat (limited to 'app/src/main/java/github')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/view/CardView.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/view/CardView.java b/app/src/main/java/github/daneren2005/dsub/view/CardView.java
new file mode 100644
index 00000000..ba6b66a4
--- /dev/null
+++ b/app/src/main/java/github/daneren2005/dsub/view/CardView.java
@@ -0,0 +1,50 @@
+package github.daneren2005.dsub.view;
+
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Canvas;
+import android.graphics.Path;
+import android.graphics.RectF;
+import android.os.Build;
+import android.util.AttributeSet;
+import android.widget.FrameLayout;
+
+import github.daneren2005.dsub.R;
+
+public class CardView extends FrameLayout{
+ public CardView(Context context) {
+ super(context);
+ this.setClipChildren(true);
+ this.setBackgroundResource(R.drawable.card_rounded_corners);
+ }
+
+ public CardView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ this.setClipChildren(true);
+ this.setBackgroundResource(R.drawable.card_rounded_corners);
+ }
+
+ public CardView(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ this.setClipChildren(true);
+ this.setBackgroundResource(R.drawable.card_rounded_corners);
+ }
+
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+ public CardView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
+ super(context, attrs, defStyleAttr, defStyleRes);
+ this.setClipChildren(true);
+ this.setBackgroundResource(R.drawable.card_rounded_corners);
+ }
+
+ @Override
+ public void onDraw(Canvas canvas) {
+ Path clipPath = new Path();
+
+ float roundedDp = getResources().getDimension(R.dimen.Card_Radius);
+ clipPath.addRoundRect(new RectF(canvas.getClipBounds()), roundedDp, roundedDp, Path.Direction.CW);
+ canvas.clipPath(clipPath);
+ super.onDraw(canvas);
+ }
+}