안드로이드/학습
[Android] 버튼 디자인 미적용
문바리
2022. 5. 23. 12:07
728x90
1. 개요
버튼에 커스텀 배경이 안되길래 구글링을 했다.
전에도 했는데 기억이 안나 정리를 해볼려고 한다.
2. 본문
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:width="1dp"
android:color="@color/hawkes_blue" />
<corners android:radius="4dp" />
<solid android:color="@color/trans100" />
</shape>
버튼 디자인을 커스텀으로 만들어놨다. 이를 버튼의 background에 적용해보자.
딱 봐도 이상하다. 분명 hawkes_blue는 회색인데 보라색이 아직도 적용된 모습이여 구글링을 했다.
<android.widget.Button
android:id="@+id/btn_merchandise_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bg_rect_hawkes_blue_trans100_round4_stoke1"
android:fontFamily="@font/helveticaneue_regular"
android:minWidth="0dp"
android:minHeight="0dp"
android:paddingStart="8dp"
android:paddingTop="6dp"
android:paddingEnd="8dp"
android:paddingBottom="7dp"
android:text="@string/content_merchandise_add"
android:textColor="@color/midnight_express"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
Button -> android.widget.Button으로 변경하면 적용이 된다.
테마를 바꾸거나 backgroundTint = @null로 변경도 가능한데 이 방법이 확실하고 편하다.
이제 깔끔하게 커스텀한 버튼 배경이 적용된다.
3. 마무리
이번에 해커톤 참여하면서도 왜 디자인이 안먹지..? 라는 생각과 동시에 예전에 한 기억이 떠올랐다.
버튼에 커스텀 디자인은 많이 사용하니 기억해두자.
반응형