티스토리 뷰

Error:(74, 31) Dimension types not allowed 오류에 대한 대처법


클라이언트로 부터 받은 요구사항은 "버튼에 올라가는 텍스트에 그림자 효과"를 넣어 달라 였다.


아래는 기존 코드와 버튼 이미지


1
2
3
4
5
6
7
8
9
<Button
            android:id="@+id/ok_action"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#F44336"
            android:elevation="6dp"
            android:textColor="#ffffff"
            android:textSize="20dp"
            android:text="확인" />
cs



그림자 효과를 넣기위해 ShadowDx,Dy,Radius등을 추가하려고 한다.


아래는 수정된 코드 (굵은 글씨가 추가된 것)


1
2
3
4
5
6
7
8
9
10
11
12
        <Button
            android:id="@+id/ok_action"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#F44336"
            android:shadowDx="2dp"
            android:shadowDy="3dp"
            android:shadowColor="#000000"
            android:shadowRadius="1.5dp"
            android:textColor="#ffffff"
            android:textSize="20dp"
            android:text="확인" />
cs


이렇게 코드를 수정하고 빌드를 했는데 띠용

Error:(74, 31) Dimension types not allowed 라는 에러가 발생했다.


stack overflow에서 원인을 검색해보니, 그림자에는 단위를 입력하지 않는 다는 것이었다.


shadowDx="2dp" ▶ shadowDx="2" 이렇게 수정했다.


아래는 정상적으로 수정된 최종코드와 버튼 이미지


1
2
3
4
5
6
7
8
9
10
11
12
        <Button
            android:id="@+id/ok_action"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#F44336"
            android:shadowDx="2"
            android:shadowDy="3"
            android:shadowColor="#000000"
            android:shadowRadius="1.5"
            android:textColor="#ffffff"
            android:textSize="20dp"
            android:text="확인" />
cs


정상적으로 텍스트에 그림자가 적용되는 것을 확인할 수 있다.




댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함