반응형
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="첫번째 버튼"
android:id="@+id/button1"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="두번째 버튼"
android:id="@+id/button2"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="세번째 버튼"
android:id="@+id/button3"
android:layout_weight="1"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="네번째 버튼"
android:id="@+id/button4"
android:layout_weight="1"
/>
</LinearLayout>
</LinearLayout>
- match_parent : 부모 컨테이너가 가지는 길이와 같게 해 준다
- wrap_content: 필요한 길이만 사용한다
- @+id : 새로 선언하는 리소스 아이디를 등록하겠다
- @id: 기존에 사용하고 있던 리소스 아이디를 참조하겠다
Linear Layout: vertical
Linear Layout: horizental
반응형
'자린고비 독학하기 > 자린고비 코딩하기' 카테고리의 다른 글
Android Studio - Relative Layout (0) | 2019.08.21 |
---|---|
Android Studio - Linear Layout: gravity / margin (0) | 2019.08.21 |
Android Studio - dependency 추가하는 법 (0) | 2019.08.21 |
Android Studio - Setting / mainActivity (0) | 2019.08.21 |
JAVA - 클래스 변수, 인스턴스 변수, 지역 변수 (0) | 2019.08.09 |