print("와챠의 개발 기록장")
[안드로이드] 직접 풀어보기 5-1 본문
반응형
직접 풀어보기 5-1
리니어 레이아웃으로 다음 화면을 구정하는 XML을 작성하라.
- 리니어 레이아웃의 orientation은 vertical로 한다.
- 버튼 3개를 생성하고 버튼의 layout_width는 100dp, layout_height는 100dp로 한다.
- 버튼에 gravity와 layout_gravity를 모두 설정해야 한다.

내껀 가상 폰 화면이 더 커서... 버튼이 저렇게 떨어져 있는 듯
activity_main.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context=".MainActivity" | |
android:orientation="vertical"> | |
<Button | |
android:layout_width="100dp" | |
android:layout_height="100dp" | |
android:text="버튼1" | |
android:layout_gravity="center" | |
android:gravity="top|right" | |
android:textSize="20dp" | |
android:padding="2dp" | |
android:textColor="#000000" | |
android:backgroundTint="#86E57F"/> | |
<Button | |
android:layout_width="100dp" | |
android:layout_height="100dp" | |
android:text="버튼2" | |
android:layout_gravity="left" | |
android:gravity="left|center" | |
android:textSize="20dp" | |
android:padding="2dp" | |
android:textColor="#000000" | |
android:backgroundTint="#86E57F"/> | |
<Button | |
android:layout_width="100dp" | |
android:layout_height="100dp" | |
android:text="버튼3" | |
android:layout_gravity="right" | |
android:gravity="bottom|right" | |
android:textSize="20dp" | |
android:padding="2dp" | |
android:textColor="#000000" | |
android:backgroundTint="#86E57F"/> | |
</LinearLayout> |
반응형
'코딩 일기장 > Android(Kotlin)' 카테고리의 다른 글
[안드로이드] 직접 풀어보기 5-3 (0) | 2021.03.20 |
---|---|
[안드로이드] 직접 풀어보기 5-2 (0) | 2021.03.20 |
[안드로이드] 4장 연습문제 9번 (0) | 2021.03.20 |
[안드로이드] 4장 연습문제 8번 (0) | 2021.03.20 |
[안드로이드] 4장 연습문제 7번 (0) | 2021.03.20 |