Table of contents

  1. CustomDrawable + ImageButton + RippleEffect
  2. Layout
  3. Theme

CustomDrawable + ImageButton + RippleEffect

Layout

  • FrameLayout: 오른쪽 하단에 위치 시키기 android:layout_gravity="bottom"
  • TextView: 텍스트 가운데 정렬 android:gravity="center"

Theme

Theme color 가져오기

TypedValue typedValue = new TypedValue();
Theme theme = context.getTheme();
theme.resolveAttribute(R.attr.theme_color, typedValue, true);
@ColorInt int color = typedValue.data;

Context 에 extension method 로 theme color 가져오기

@ColorInt
fun Context.getColorFromAttr(
    @AttrRes attrColor: Int,
    typedValue: TypedValue = TypedValue(),
    resolveRefs: Boolean = true
): Int {
    theme.resolveAttribute(attrColor, typedValue, resolveRefs)
    return typedValue.data
}
textView.setTextColor(getColorFromAttr(R.attr.color))