안드로이드 공부/ 뷰의 영역

Margin

  • 이 view가 다른 것(ex:부모 view)과 얼마나 안쪽으로 떨어뜨릴지 결정
  • ⌨ 예시 코드
<?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">

    <TextView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:text="안녕하세요"
        android:background="#FD9F9F"
        android:layout_marginTop="20dp"
        android:layout_marginLeft="50dp"
        />

</LinearLayout>
  • 예시 코드 결과

Padding

  • view가 가지고 있는 contents가 얼마나 안쪽으로 떨어뜨릴지 결정

  • ⌨ 예시 코드

<?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">
    
    <TextView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:text="안녕하세요"
        android:background="#C4FA85"
        android:paddingLeft="15dp"
        android:paddingTop="30dp"
        />
    
</LinearLayout>
  • 예시 코드 결과

좋은 웹페이지 즐겨찾기