티스토리 뷰
[Android Studio] 버튼 둥글게 만들기 안드로이드 스튜디오 Button Round
안드로이드 애플리케이션을 보면 버튼이 둥글게 되어있는 App들이 있다.
오늘은 딱딱한 안드로이드 버튼에서 둥근 버튼으로 바꾸는 법을 배워보자
우선 resource 경로 아래 drawable 폴더에 신규 drawable resource file(xml)을 생성해준다.
파일명은 원하는 파일명을 소문자로 작성한다.
resource file명은 대문자 사용이 불가하다.
생성한 xml파일에 아래 코드를 작성한다.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp"
android:shape="rectangle" >
<solid android:color="#000000" />
<corners
android:bottomLeftRadius="12dp"
android:bottomRightRadius="12dp"
android:topLeftRadius="12dp"
android:topRightRadius="12dp" />
</shape>
Radius값을 조정하여 둥근 크기를 조절할 수 있고 solid color 부분에서 원하는 버튼 색을 지정할 수 있다.
이후 activity_main에서 버튼을 생성한다.
<Button
android:id="@+id/btn_pass"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:background="@drawable/button_round"
android:layout_marginRight="35dp"
android:layout_marginLeft="35dp"
android:text="로그인"
android:textColor="#fff"
android:textSize="20sp"
android:textStyle="bold" />
필자는 로그인이라는 버튼을 만들었다.
android:background="@drawable/button_round"
backgournd 속성을 이용하여 만들었던 resource파일을 작성해주면 버튼이 둥글게 바뀌었을 것이다.
'안드로이드 > XML' 카테고리의 다른 글
[Android Studio] 배경 그라데이션 효과 주기 안드로이드 스튜디오 (0) | 2021.04.05 |
---|---|
[Android Studio] 간단한 커스텀 폰트 사용하기 원하는 글꼴 넣기 안드로이드 스튜디오 (0) | 2020.11.02 |
[Android Studio] 버튼 누르는 효과 만들기 클릭 이벤트 효과 Button Press 안드로이드 스튜디오 (0) | 2020.10.24 |
[Android studio] 버튼클릭 지점부터 물결효과 주기 Button ripple 안드로이드 스튜디오 (0) | 2020.10.21 |
[Android Studio] 간단하게 일정시간 지연시키는 딜레이주기 Delay 안드로이드 스튜디오 (0) | 2020.10.20 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 깃랩에서 깃허브로
- react native 오픈소스 라이선스
- 깃허브 잔디 옮기기
- Android Studio
- next useEffect
- non-zero exit code detected
- kakao api notworking
- 깃허브에서 깃랩으로
- react.js useEffect
- react native oss
- room error
- nextjs ssr deploy
- 라이브러리 라이센스
- kotlin
- 커밋 이메일 변경
- github mirror
- 코틀린
- 안드로이드 스튜디오 해시키
- 깃랩 잔디 옮기기
- rn 오픈소스 라이센스
- gitlab mirror
- 안드로이드 해시키
- next.js ssr deploy
- next.js useEffect
- Build failed because of webpack errors
- 카카오 해시키
- rn oss
- amplify next.js
- 안드로이드 스튜디오
- amplify build error
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함