android studio의 activity design 화면과 AVD 또는 실제 디바이스에서 미세한 차이가 발생합니다.

조회수 3289회

안녕하세요. 안드로이드 스튜디오의 activity design 화면과 AVD나 실제 디바이스 화면과 미세한 차이가 발생합니다.

안드로이드 스튜디오의 activity design 화면에서는 아래 그림처럼 숫자가 들어가는 부분이 나눗셈 기호 중간 쯤에 자리하는데요.(타이틀바를 삭제하기 위해 API 19 화면으로 보고 있습니다.)

이미지

AVD에서는 숫자가 좀 더 아래로 내려온 것을 확인할 수 있습니다.

이미지

또 다른 AVD인데 역시 안드로이드 스튜디오의 activity design 화면과 미세한 차이가 납니다.

이미지

실제 디바이스도 마찬가지구요. 이렇게 activity design 화면과 차이가 있기 때문에 activity design 화면을 100% 신뢰할 수 없는건가요? 이렇게 발생하는 미세한 차이는 어느정도 감으로 코딩해야 하나요?

  • (•́ ✖ •̀)
    알 수 없는 사용자

2 답변

  • 안드로이드 스튜디오에서 레이아웃 프리뷰의 설정을 실제 디바이스와 동일하게 선택해보세요. 제Nexus 6P에서 프리뷰와 실제 디바이스의 차이를 느끼기 어려운 수준입니다.(제가 감이 떨어질 수도 있지만)

    개인적으로는 프리뷰에서 레이아웃의 구성, 위치, 틀어진 곳은 없는지 등을 러프하게 확인하는 용도로 사용하고 있고, 최종 디자인은 디바이스에서 확인하는 편입니다.

    이미지

    • (•́ ✖ •̀)
      알 수 없는 사용자
  • Component Tree를 보시면 아시겠지만 FrameLayout으로 나누기 이미지를 밑에 깔고 그 위로 Linearlayout에 숫자들이 들어가 있는 상태입니다. Android Studio의 Design 창에서는 그림처럼 보이지만 실제 Device에서 또는 AVD 화면에서는 숫자들이 들어가 있는 LinearLayout이 약간 아래로 밀려나서 출력되는 것입니다.

    이미지

    일단 감으로 마진을 줘서 문제는 해결했는데... 혹시 전문가들께서는 원인을 알고 계시지 않을까 싶어 좀 더 구체적인 정보를 남깁니다.

    해당 Fragment의 소스 코드입니다. FrameLayout 위에 RelativeLayout과 LinearLayout이 올라와 있는 것을 확인할 수 있습니다.

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
    
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="37dp"
                android:src="@drawable/div_sign_long"
                android:layout_centerHorizontal="true"
                android:id="@+id/div_sign" />
    
        </RelativeLayout>
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
    
            <LinearLayout
                android:id="@+id/quotient"
        ...
    
    

    위 Fragment를 담을 Activity의 소스코드입니다. Frament가 들어가는 위치는 fragment_container라는 FrameLayout입니다.

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent" android:layout_height="wrap_content">
        <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="vertical"
            android:id="@+id/main_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:paddingBottom="10dp"
            android:background="#ffffff">
    
            <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/fragment_container"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true" />
    
            <fragment
                xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                android:id="@+id/numberPadFragment"
        ...
    
    

    마진이나 패딩, 기타 어떤 View의 속성에 의해 저런 현상이 벌어지는 것은 아닌지... 아니면 원래 저러는 것인지 정말 궁금한데 확실한 답변을 못 찾겠네요.

    • (•́ ✖ •̀)
      알 수 없는 사용자

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)