diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/view/CardView.java | 50 | ||||
-rw-r--r-- | app/src/main/res/drawable/card_rounded_corners.xml | 6 | ||||
-rw-r--r-- | app/src/main/res/layout/basic_cell_item.xml | 65 | ||||
-rw-r--r-- | app/src/main/res/values/dimens.xml | 1 |
4 files changed, 92 insertions, 30 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); + } +} diff --git a/app/src/main/res/drawable/card_rounded_corners.xml b/app/src/main/res/drawable/card_rounded_corners.xml new file mode 100644 index 00000000..5475c3d6 --- /dev/null +++ b/app/src/main/res/drawable/card_rounded_corners.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<shape xmlns:android="http://schemas.android.com/apk/res/android"> + <solid android:color="@android:color/white"/> + <corners android:radius="@dimen/Card.Radius"/> + <padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" /> +</shape>
\ No newline at end of file diff --git a/app/src/main/res/layout/basic_cell_item.xml b/app/src/main/res/layout/basic_cell_item.xml index f522b196..0ccf78bd 100644 --- a/app/src/main/res/layout/basic_cell_item.xml +++ b/app/src/main/res/layout/basic_cell_item.xml @@ -1,39 +1,44 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" +<github.daneren2005.dsub.view.CardView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" - android:layout_height="match_parent" - android:background="?attr/selectableItemBackground"> - - <github.daneren2005.dsub.view.SquareImageView - android:id="@+id/item_art" - android:layout_width="match_parent" - android:layout_height="match_parent"/> + android:layout_height="match_parent"> <LinearLayout + android:orientation="vertical" android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="horizontal" - android:paddingTop="4dp" - android:paddingLeft="2dp"> + android:layout_height="match_parent" + android:background="?attr/selectableItemBackground"> - <TextView - android:id="@+id/item_name" - android:layout_width="0dp" - android:layout_height="wrap_content" - android:layout_weight="1" - android:textAppearance="?android:attr/textAppearanceMedium" - android:singleLine="true" - android:ellipsize="marquee" - android:textColor="?android:textColorPrimary"/> + <github.daneren2005.dsub.view.SquareImageView + android:id="@+id/item_art" + android:layout_width="match_parent" + android:layout_height="match_parent"/> - <ImageView - android:id="@+id/item_more" - android:src="?attr/download_none" - android:layout_width="wrap_content" + <LinearLayout + android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_gravity="right|center_vertical" - android:paddingRight="2dp" - style="@style/BasicButton"/> + android:orientation="horizontal" + android:paddingTop="4dp" + android:paddingLeft="2dp"> + + <TextView + android:id="@+id/item_name" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:textAppearance="?android:attr/textAppearanceMedium" + android:singleLine="true" + android:ellipsize="marquee" + android:textColor="?android:textColorPrimary"/> + + <ImageView + android:id="@+id/item_more" + android:src="?attr/download_none" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="right|center_vertical" + android:paddingRight="2dp" + style="@style/BasicButton"/> + </LinearLayout> </LinearLayout> -</LinearLayout>
\ No newline at end of file +</github.daneren2005.dsub.view.CardView>
\ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 23a3f4a3..c63976f4 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -6,4 +6,5 @@ <dimen name="AlbumArt.Small">78dip</dimen> <dimen name="AlbumArt.Header">120dip</dimen> <dimen name="Star.Small">20dp</dimen> + <dimen name="Card.Radius">4dp</dimen> </resources>
\ No newline at end of file |