반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- 리액트프로젝트
- two pointers
- CSS
- MSA
- Bambino
- sql
- 웹개발
- msa개념
- coding test
- DB
- job
- SpringFramework
- jvm메모리구조
- BCIT
- 데이터베이스
- C
- Programming
- jsp
- MVC
- 자바
- 웹개발자
- 웹개발기초
- 밤비노
- 코드잇
- servlet
- microservices
- mysql
- html
- Java
- 안드로이드
Archives
- Today
- Total
초보 개발자의 기록
GUI 컴포넌트 종류와 이용 본문
728x90
버튼, TextView(라벨), editText(텍스트박스), Radio, Scroll, ImageView...
LinearLayout = java의 flowLayout과 흡사
MainActivity.java
package com.study.app0119;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Button;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_main);
//화면에 버튼 나오게 하자
//Alt+Enter = import
Button bt = new Button(this);
bt.setText("나의 첫 버튼");
//화면에 부착
//this.setContentView(bt);
//로컬 pc가 아닌 스마트폰이므로, 드라이브를 지정할 수 없으므로
//정해둔 res 디렉토리 밑에서 찾아갈 수 있도록하자
//res를 R.java 파일로 관리
//파일이름은 상수로 관리 - 실시간으로 등록되어있음
this.setContentView(R.layout.linear); //레이아웃 xml의 경로 및 파일명
//결론: 응용어플리케이션에서는 화면 배치가 중요하다
}
}
linear.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="난 버튼" />
</LinearLayout>
이미지는 소문자로 시작, 숫자로시작 불가능, drawable에 위치
linear.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFC107"
android:orientation="vertical">
<!--
리니어 레이아웃은?
선형레이아웃으로써, 내부의 자식 컴포넌트들을 일렬로 배치
일렬 방향은 두 가지
1> 수직 :Vertical
2> 수평 :Horizontal
-->
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="난 버튼" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/avocado" />
<!--텍스트 입력-->
<!-- hint = placeholder-->
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="여기에 텍스트 입력"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:hint="여기에 연락처 입력"/>
<Switch
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Switch"/>
<CheckBox
android:id="@+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CheckBox"/>
<ProgressBar
android:id="@+id/progressBar2"
style="?android:attr/progressBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<SurfaceView
android:id="@+id/surfaceView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
728x90
반응형
'Android' 카테고리의 다른 글
첫 버튼 생성 (0) | 2021.01.22 |
---|---|
Android Studio 기본 설명 (0) | 2021.01.22 |
안드로이드 설명 (0) | 2021.01.22 |
안드로이드-개발환경 구축 (0) | 2021.01.22 |