Skip to content

Commit

Permalink
[#13] 뱃지가 달린 Round Image View 추가
Browse files Browse the repository at this point in the history
- 기존 CardView 사용방식에서 ShapeableImageView 사용으로 변경
  • Loading branch information
DongJun-H committed Mar 24, 2022
1 parent 93aaf58 commit 04f846c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class BadgeRoundImageView : ConstraintLayout {
this.height = bigCircleSize
this.width = bigCircleSize
}
binding.viewBigCircle.radius = bigCircleSize.toFloat()
}

binding.imgBadgeSymbol.apply {
Expand All @@ -59,7 +58,6 @@ class BadgeRoundImageView : ConstraintLayout {
this.height = badgeSize
this.width = badgeSize
}
binding.viewBadge.radius = badgeSize.toFloat()
}
typedArray.recycle()
}
Expand All @@ -75,7 +73,6 @@ class BadgeRoundImageView : ConstraintLayout {
this.height = imgSize
this.width = imgSize
}
binding.viewBigCircle.radius = imgSize.toFloat()
}
fun setBadgeImgSrc(imgResId: Int) {
binding.imgBadgeSymbol.setImageResource(imgResId)
Expand All @@ -88,6 +85,5 @@ class BadgeRoundImageView : ConstraintLayout {
this.height = imgSize
this.width = imgSize
}
binding.viewBadge.radius = imgSize.toFloat()
}
}
28 changes: 9 additions & 19 deletions app/src/main/res/layout/view_badge_round_image.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,20 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:id="@+id/view_big_circle"
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/img_big_circle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardElevation="0dp"
app:shapeAppearanceOverlay="@style/RoundImageView"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<ImageView
android:id="@+id/img_big_circle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/view_badge"
app:layout_constraintEnd_toEndOf="parent"/>
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/img_badge_symbol"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardElevation="0dp"
app:layout_constraintBottom_toBottomOf="@+id/view_big_circle"
app:layout_constraintEnd_toEndOf="@+id/view_big_circle">
<ImageView
android:id="@+id/img_badge_symbol"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</androidx.cardview.widget.CardView>
app:shapeAppearanceOverlay="@style/RoundImageView"
app:layout_constraintBottom_toBottomOf="@+id/img_big_circle"
app:layout_constraintEnd_toEndOf="@+id/img_big_circle"/>
</androidx.constraintlayout.widget.ConstraintLayout>
7 changes: 7 additions & 0 deletions app/src/main/res/values/styles_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="RoundImageView">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">50%</item>
</style>
</resources>

0 comments on commit 04f846c

Please sign in to comment.