자린고비 독학하기/자린고비 코딩하기
Android Studio - Linear Layout: 위젯 추가
lafee
2019. 8. 21. 15:05
반응형
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
반응형