Home 8월 18일 Today I Learned
Post
Cancel

8월 18일 Today I Learned

오늘 한 일

  • A·아이 프로젝트를 진행하였다
  • 블로그 TIL을 작성하였다
  • 1일 1커밋을 하였다

느낀 점

안드로이드에서 개발을 하면서 xml 웬만한 속성은 다 안다고 생각했었는데 layout_marginBaseline 같이 내 기억상으로 아예 처음보는 코드가 있다는 걸 보고 아직도 배울 것이 많구나라고 다시 한번 느끼게 되었다 그래도 이런 식으로 모르는 것에 대해 찾아보고 공부하고 정리하는 식으로 계속하다 보면 언젠가는 다 알게 되지 않을까

배운 점

Android layout_marginBaseline 속성

layout_marginBaseline은 XML 레이아웃 파일에서 사용되는 속성 중 하나로 뷰의 상단(높이의 기준선)과 상위 뷰의 하단(높이의 기준선) 사이의 간격을 설정하는데 사용되며 주로 텍스트 뷰나 인라인 텍스트 요소가 포함된 뷰를 정렬하는데 유용하게 쓸 수 있다

예를 들어 TextView가 있는 레이아웃에서 TextView의 기준선을 기준으로 다른 View를 정렬하거나 간격을 설정하고 싶을 때 layout_marginBaseline을 사용할 수 있다

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<TextView
    android:id="@+id/textView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello World!"
    android:layout_marginBaseline="16dp" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Button"
    android:layout_marginTop="16dp"
    android:layout_marginStart="16dp"
    android:layout_marginEnd="16dp"
    android:layout_below="@id/textView"
    android:layout_marginBaseline="@id/textView" />

위와 같이 Button의 상단 간격과 좌우 여백을 설정할 때 layout_marginBaseline 속성을 사용하여 Button의 상단을 TextView의 베이스라인에 맞춰 텍스트와 버튼을 정렬할 수 있다

내일 계획

내일은 A·아이 프로젝트 진행해야겠다

This post is licensed under CC BY 4.0 by the author.

8월 17일 Today I Learned

안드로이드 Firebase Realtime Database does not define a no-argument constructor 오류