[android] Android 태블릿 용 레이아웃

Android에서 태블릿 및 핸드셋에 대해 다른 레이아웃을 만들고 싶습니다. 이러한 차별화를 위해 레이아웃 리소스를 어디에 배치해야합니까?



답변

나는 이것이 오래된 질문이라는 것을 알고 있지만 그것을 위해 … 문서 에 따르면 다음과 같은 여러 자산 폴더를 만들어야합니다.

res/layout/main_activity.xml           # For handsets (smaller than 600dp available width)
res/layout-sw600dp/main_activity.xml   # For 7” tablets (600dp wide and bigger)
res/layout-sw720dp/main_activity.xml   # For 10” tablets (720dp wide and bigger)


답변

코드에서 Fragment 개념을 사용하는 경우 (다중 창 레이아웃을 의미 함) swdp 대신 wdp를 사용하는 것이 가장 좋습니다.

res/layout-w600dp/main_activity.xml   # For 7” tablets (600dp wide and bigger)
res/layout-w720dp/main_activity.xml   # For 10” tablets (720dp wide and bigger)
res/layout-w600dp-land/main_activity.xml   # For 7” tablets in landscape (600dp wide and                  bigger)
res/layout-w720dp-land/main_activity.xml   # For 10” tablets in landscape (720dp wide and bigger)

wdp를 이해하려면 표를 참조하십시오.

Table 2. New configuration qualifers for screen size (introduced in Android 3.2).
다음 링크
http://developer.android.com/guide/practices/screens_support.html


답변

레이아웃을 사용하면 현재 다음 사항에 의해서만 차별화 할 수 있다고 생각합니다.

res/layout/my_layout.xml            // layout for normal screen size
res/layout-small/my_layout.xml      // layout for small screen size
res/layout-large/my_layout.xml      // layout for large screen size
res/layout-large-land/my_layout.xml // layout for large screen size in landscape mode

여기 에서 다른 설정을 구분하기 위해 폴더 구조에 추가 할 수있는 항목에 대한 자세한 정보를 찾을 수 있습니다 .

가장 큰 문제는 Android SDK가 공식적으로 태블릿을 통합하지 않았다는 것입니다. 이 문제는 다음 Android 버전에서 해결되기를 바랍니다. 그렇지 않으면 모든 화면 크기에서 작동하는 크기 조정 레이아웃을 사용하는지 확인하기 만하면됩니다.


답변

문서에 따르면 다음과 같은 여러 자산 폴더를 만들어야합니다. 전체 목록 ……

res/layout/main_activity.xml  // For handsets (smaller than 600dp available width)
res/layout/main_activity.xml  // For handsets (smaller than 600dp available width)
res/layout-sw600dp/main_activity.xml  // For 7” tablets (600dp wide and bigger) 
res/layout-sw720dp/main_activity.xml  // For 10” tablets (720dp wide and bigger)
res/layout-sw600dp-land/main_activity.xml  // For 7” tablets in landscape (600dp wide and bigger)
res/layout-sw720dp-land/main_activity.xml  // For 10” tablets in landscape (720dp wide and bigger)


답변

이 소스 는 또한 언어, 화면 너비 / 높이, 레이아웃 방향, 화면 방향 등 기기 구성을 기반으로 리소스를 호출하는 방법을 제공합니다.

태블릿 용 고품질 아이콘을 호출하는 것과 같이 소스가 언급 한 기본 리소스를 만들려면주의해야합니다.


답변

아래와 같이 Android 스튜디오의 ‘미리보기 방향’드롭 다운은 빠른 가로 및 태블릿 레이아웃 xml을 생성하는 데 도움이 될 수 있습니다. 또한 별도의 폴더 즉 생성 layout-land하고 layout-sw600dp이러한 레이아웃의 변화에 대한 이러한 폴더 내에 레이아웃 XMLS 놓습니다.
여기에 이미지 설명 입력


답변