달력

4

« 2024/4 »

  • 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
2011. 8. 26. 00:31

Relative Layout 예제 중 명함예제 Study/Android2011. 8. 26. 00:31

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="#ffffff"
    android:padding="5dip"
    >
<ImageView 
android:id="@+id/pic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/picman"
/>
<TextView 
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4px"
android:layout_toRightOf="@id/pic"
android:textSize="20sp"
android:text="홍길동"
/>
<TextView 
android:id="@+id/phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignBaseline="@id/title"
android:textSize="12sp"
android:text="015-123-4567"
/>
<Button 
android:id="@+id/delButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/pic"
android:text="Del"
/>
<TextView 
android:id="@+id/contents"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/delButton"
android:layout_below="@id/title"
android:layout_alignLeft="@id/title"
android:layout_centerVertical="true"
android:text="우리 딸래미가 처음 그린 그림이다. 누구를 그린것인지는 알 수 없으나 머리카락이 몇올 없는 것으로 보아 갓 태어난 동새을 그린 것으로
추측된다. 본인도 기억이 나지 않는다 하여 확인할 방법은 없다."
/>

</RelativeLayout>


문제점분석

1) 전화번호 배치 틀린이유

android:layout_alignParentRight="true" 와 동시에 android:layout_toRightOf="@id/title" 를 썼더니 

title에 바짝 붙어버렸다. 아예 오른쪽 정렬을 하고자 할때는 alignParentRight가 맞구나.
(사실 좀만 생각해봐도 나왔을 답이였는데)

2) Contents 배치가 겹쳐버린 이유
android:layout_alignLeft="@id/title" 요부분 빼먹어서.


이런거 한번해보니까 배치가 어떻게 돌아가는지 충분히 감이 오는구마....


'Study > Android' 카테고리의 다른 글

getSystemService  (0) 2011.08.29
Style / Theme  (0) 2011.08.29
Notification 공부 정리  (0) 2011.08.29
getVisibility와 View.GONE View.INVISIBLE  (0) 2011.08.26
layout_alignWithParentIfMissing  (0) 2011.08.26
LinerLayout 추가 기록  (0) 2011.08.25
Android process 개략설명  (0) 2011.08.25
AndroidManifest 개략 설명  (0) 2011.08.25
Activity Life Cycle  (0) 2011.08.25
layout_gravity vs gravity  (0) 2011.08.25
:
Posted by 유쾌한순례자