diff --git a/app/src/main/java/com/rayworks/droidweekly/MyViewHolder.java b/app/src/main/java/com/rayworks/droidweekly/MyViewHolder.java index 455aa37..8a674bb 100644 --- a/app/src/main/java/com/rayworks/droidweekly/MyViewHolder.java +++ b/app/src/main/java/com/rayworks/droidweekly/MyViewHolder.java @@ -4,6 +4,8 @@ import android.content.res.ColorStateList; import android.content.res.Resources; import android.graphics.Color; +import android.graphics.drawable.GradientDrawable; +import android.os.Build; import android.support.v4.view.ViewCompat; import android.support.v7.widget.RecyclerView; import android.text.TextUtils; @@ -42,8 +44,19 @@ public void bind(ArticleItem item) { String imageUrl = item.getImageUrl(); if (!TextUtils.isEmpty(imageUrl)) { imageParent.setVisibility(View.VISIBLE); - ViewCompat.setBackgroundTintList( - imageParent, ColorStateList.valueOf(item.getImgFrameColor())); + + int frameColor = item.getImgFrameColor(); + + View targetView = imageParent; + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { + // apply a different layout + // ref: https://stackoverflow.com/questions/4772537/i-need-to-change-the-stroke-color-to-a-user-defined-color-nothing-to-do-with-th + targetView = itemView.findViewById(R.id.frame_view); + GradientDrawable drawable = (GradientDrawable) targetView.getBackground(); + drawable.setStroke(1, frameColor); + } else { + ViewCompat.setBackgroundTintList(targetView, ColorStateList.valueOf(frameColor)); + } Glide.with(itemView).load(imageUrl).into(imageView); } else { diff --git a/app/src/main/res/drawable/rect_image_frame.xml b/app/src/main/res/drawable/rect_image_frame.xml index eeb7fc9..0d149c7 100644 --- a/app/src/main/res/drawable/rect_image_frame.xml +++ b/app/src/main/res/drawable/rect_image_frame.xml @@ -1,6 +1,8 @@ - + + \ No newline at end of file diff --git a/app/src/main/res/layout-v21/view_news_item.xml b/app/src/main/res/layout-v21/view_news_item.xml new file mode 100644 index 0000000..cba0c69 --- /dev/null +++ b/app/src/main/res/layout-v21/view_news_item.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/view_news_item.xml b/app/src/main/res/layout/view_news_item.xml index cba0c69..921c1a7 100644 --- a/app/src/main/res/layout/view_news_item.xml +++ b/app/src/main/res/layout/view_news_item.xml @@ -9,45 +9,53 @@ android:descendantFocusability="beforeDescendants"> + android:layout_marginStart="16dp"> - + + - + android:orientation="vertical"> + + + + + - \ No newline at end of file