[2023 Free Kotlin Lecture] Android Programming A-Z, from Basics to Profit Generation
Relative Layout
버튼모양 질문 소스코드 첨부
146
7 asked
강의대로 소스코드 입력했는데도 원으로 나옵니다.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--레이아웃 기준으로 배치하기-->
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:text="parent\nstart"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:text="parent\nend"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="parent bottom"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:text="parent bottom\n + parent end"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="parent\ncenter"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="center\nhorizontal"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="center\nvertical"/>
</RelativeLayout>
Answer 1
0
안녕하세요, 인프런 AI 인턴입니다.
재철님, 버튼이 원 모양으로 나오는 이유는 주어진 소스 코드에는 버튼의 모양을 원으로 만드는 특정 속성이 명시되어 있지 않기 때문입니다. Android에서 버튼을 원 모양으로 만들고자 할 때는 주로 버튼의 배경에 원 모양의 drawable을 설정하거나, 버튼의 width와 height를 같게 설정하고, background 속성에 원 모양을 정의한 drawable 리소스를 사용합니다. 하지만, 제공해주신 XML 코드에는 이러한 설정이 포함되어 있지 않습니다. 따라서 버튼이 원 모양으로 나오는 것과 관련된 코드나 설정이 누락되었거나, 다른 곳에서 해당 설정이 적용되었을 가능성이 있습니다.
원 모양의 버튼을 구현하려면 다음과 같은 방법을 사용할 수 있습니다.
res/drawable폴더 내에 원 모양의 배경을 갖는 XML 파일을 생성합니다. 예를 들어circle_shape.xml파일을 만들고 내용으로 원 모양의 정의를 포함시킵니다.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#FF0000"/>
</shape>
- 버튼의
android:background속성에 이 drawable을 설정합니다.
<Button
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@drawable/circle_shape"
android:text="원 모양 버튼"/>
이 방법으로 버튼의 배경을 원형으로 설정할 수 있습니다. 만약 버튼이 여전히 원 모양으로 나오지 않는다면, 다른 스타일이나 테마 설정이 영향을 주고 있을 수 있으니 확인해 보세요.
안드로이드스튜디오 버전이 어떻게 되는지요?
0
106
1
스크래치 파일 Run 안되는 오류 발생
0
134
1
Git에서 다운받은 폴더가 안열리는 분들
0
136
1
TodoDao Interface 문의
0
78
1
kotlin 버전과 ksp 버전 꼭 맞추셔야 해요!!
0
450
1
아름다운 joyce님께.. runonuithread 문의
0
139
0
viewBinding 관련 질문입니다.
0
206
3
0:30초 질문입니다.
0
179
1
Locationmanager로 타입캐스팅 실패 문의
0
140
1
Todo리스트 dao 구성 시 todo 질문
0
140
1
룸 데이터베이스 구성 시 dao 에러 문의
0
171
1
레이아웃 구성할떄 저는 버튼모양이 원으로 나와요
0
169
1
싱글톤 패턴 구현중 코드가 강의와 일치하지 않습니다.
0
156
1
MainActivity 파일안에 setContencView가 없습니다..
0
202
1
room database 설치 질문
0
174
1
kts로 공부하는 학생도 있는데 갑자기 설명도 없이 kt로 설명하면..
0
314
3
mutable과 var의 차이점
0
201
1
안드로이드 스튜디오 스크래치 파일
0
277
1
추가링크는 어디에 있을까요?
0
285
1
대시보드 설정 마지막 단계 Google Play에 앱 게시
0
678
2
geoCoder.getFromLocation 에러
0
554
2
apirequest.io 로딩 현상 & 사이트 이상함
0
451
1
PrimaryKey를 Nullable하게 만드는 이유
0
268
1
개인정보처리방침에 대한 질문
0
233
1

