Android Projects
[BMI Calculator] 레이아웃 만들기
IT Knowledge Share
2021. 7. 20. 18:03
반응형
기본적인 레이아웃 작업을 해보도록 합시다.
원하는 신장값과 체중값을 입력하면, BMI 지수가 계산되도록 할 것입니다.
입력되는 부분은 EditText 태그를 사용할 것이며, 패딩과 마진을 사용해서 간격을 조정합니다.
자주 사용되는 값과 색상은 res-values에서 별도로 설정하여 사용하도록 합니다.
그리고 각 뷰마다 아이디값을 부여하였습니다. 완성된 코드는 다음과 같습니다.
<?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"
android:orientation="vertical"
android:padding="16dp"
tools:context=".MainActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/height"
android:textColor="@color/custom_black"
android:textSize="20sp"
android:textStyle="bold" />
<EditText
android:id="@+id/heightEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:inputType="number" />
*** 이하 생략 ***
<Button
android:id="@+id/resultButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:text="@string/confirm" />
</LinearLayout>
반응형