안드로이드 개발 질문/답변
(글 수 45,052)
해상도가 wvga854 인 에뮬레이터를 실행하여 아래 레이아웃을 적용했습니다.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
>
<!-- width 50px 버튼 6개 가로 방향으로 배열 -->
<Button
android:layout_width="50px"
android:layout_height="40px"
android:background="#FFFFFF"
android:text="1"
/>
<Button
android:layout_width="50px"
android:layout_height="40px"
android:background="#00FF00"
android:text="2"
/>
<Button
android:layout_width="50px"
android:layout_height="40px"
android:background="#FFFFFF"
android:text="3"
/>
<Button
android:layout_width="50px"
android:layout_height="40px"
android:background="#00FF00"
android:text="4"
/>
<Button
android:layout_width="50px"
android:layout_height="40px"
android:background="#FFFFFF"
android:text="5"
/>
<Button
android:layout_width="50px"
android:layout_height="40px"
android:background="#00FF00"
android:text="6"
/>
</LinearLayout>
이렇게 했더니 아래처럼 나옵니다.
가로 너비가 480px 이고 50px 버튼이 6개 이므로 양 옆에 90px 씩 공간이 남아야 하는데,
위 그림처럼 되는 이유가 뭔지 궁금합니다.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
>
<!-- width 50px 버튼 6개 가로 방향으로 배열 -->
<Button
android:layout_width="50px"
android:layout_height="40px"
android:background="#FFFFFF"
android:text="1"
/>
<Button
android:layout_width="50px"
android:layout_height="40px"
android:background="#00FF00"
android:text="2"
/>
<Button
android:layout_width="50px"
android:layout_height="40px"
android:background="#FFFFFF"
android:text="3"
/>
<Button
android:layout_width="50px"
android:layout_height="40px"
android:background="#00FF00"
android:text="4"
/>
<Button
android:layout_width="50px"
android:layout_height="40px"
android:background="#FFFFFF"
android:text="5"
/>
<Button
android:layout_width="50px"
android:layout_height="40px"
android:background="#00FF00"
android:text="6"
/>
</LinearLayout>
이렇게 했더니 아래처럼 나옵니다.
가로 너비가 480px 이고 50px 버튼이 6개 이므로 양 옆에 90px 씩 공간이 남아야 하는데,
위 그림처럼 되는 이유가 뭔지 궁금합니다.
2010.04.02 10:46:55
density 240 인가요????
지금 작성하신 "50px" -> "50dip" 로 바꿔도 똑같은 결과가 나온다면 작업을 dip 기준으로 하셔야 합니다.
"50px" 가 dip로 먹었다고 가정하면 50 * 1.5 = 75
75 * 6 = 450
양쪽에 대충 15 dip 정도 남는다고 보여집니다.
무슨 이유인지는 모르겠습니다. -_-;;;;;
지금 작성하신 "50px" -> "50dip" 로 바꿔도 똑같은 결과가 나온다면 작업을 dip 기준으로 하셔야 합니다.
"50px" 가 dip로 먹었다고 가정하면 50 * 1.5 = 75
75 * 6 = 450
양쪽에 대충 15 dip 정도 남는다고 보여집니다.
무슨 이유인지는 모르겠습니다. -_-;;;;;
폰마다 해상도의 차이때문에 px이 아닌 dp으로 크기를 설정하시는것을 추천합니다.