2016-09-09 2 views
0

다른 휴대 전화/태블릿 화면 크기에 맞춰 레이아웃을 지원할 때 몇 가지 문제가 있습니다. 내 레이아웃은 모든 화면에 맞지 않거나 크기가 조정되지 않습니다. 일부 화면 크기는 너무 많은 공간을 제공하고 다른보기에는 모든보기를위한 공간이 없습니다.다른 전화기 화면에서 내 레이아웃을 지원하는 데 사용해야하는 한정어는 무엇입니까?

PX와 밀도/크기/크기가 다른 한정자를 사용하여 다른 레이아웃을 생성하려고 시도했습니다. 하지만 모든 화면에 완전히 적응하려면 어떤 자격 조건을 사용해야하는지 알 수 없습니다. 뷰 높이에 맞게 dosn't :

내 레이아웃 (genymotion 에뮬레이터에서 테스트) 다른 화면

480 픽셀 X 800 픽셀 240dpi (S3 미니)와 함께 작동 방법에 대한 설명입니다. X 800 픽셀 120DPI

480 픽셀 (에뮬레이터) : 조회수 높이

480 픽셀 X 800 픽셀 320dpi에 적합 dosn't : 뷰 주위 너무 많은 여유 공간.

600px x 1024px 240dpi : 완벽하게 피트!

600px x 1024px 420dpi : 아무것도 표시 할 공간이 거의 없습니다. 최대

1440px X 2560px 560dpi에서 아마 2-3 조회수 : 여유 공간이 조금

1440px X 2560px 640DPI : 딱 맞는!

1440px는 X 2560px 320DPI가 :

삼성 S3 MINI : 480 픽셀 X 800 픽셀 견해 여기

주위 너무 많은 여유 공간을 어떻게 배치 통계 다른 스크린 규모의 스크린 샷 예입니다 240dpi :https://www.dropbox.com/s/kvxggql80ivcmlp/galaxys3mini.png?dl=0

삼성 갤럭시 S7 : 1440px X 2560px 640DPI : 01,238,545,683,918,276,

넥서스 9 API (23)의 2048x1536 xhdpi는 :https://www.dropbox.com/s/r70h4da1xcf2lhi/nexus9.PNG?dl=0

어떻게 한정자를 사용한다 '?

레이아웃은 XML을 :

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@color/arion_darkblue"> 

<TextView 
    android:id="@+id/stats_title" 
    style="@style/fragment_titles_style" 
    android:layout_alignParentTop="true" 
    android:text="Stats" /> 


<RelativeLayout 
    android:id="@+id/statsgroup1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/stats_title" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="25dp"> 


    <ImageView 
     android:id="@+id/stats_distance_img" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="20dp" 
     android:background="@drawable/ic_stats_distance" /> 

    <TextView 
     android:id="@+id/stats_distance_txt" 
     style="@style/fragments_textstyles" 
     android:layout_below="@id/stats_distance_img" 
     android:text="0,0 Km" /> 

    <ImageView 

     android:id="@+id/stats_jump_img" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="10dp" 
     android:layout_marginLeft="35dp" 
     android:layout_toRightOf="@id/stats_distance_txt" 
     android:background="@drawable/ic_stats_jump" /> 

    <TextView 
     android:id="@+id/stats_jump_txt" 
     style="@style/fragments_textstyles" 
     android:layout_below="@id/stats_distance_img" 
     android:layout_marginLeft="35dp" 
     android:layout_toRightOf="@id/stats_distance_txt" 
     android:text="00" /> 

    <ImageView 
     android:id="@+id/stats_transition_img" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="65dp" 
     android:layout_toRightOf="@id/stats_jump_txt" 
     android:background="@drawable/ic_stats_transition" /> 

    <TextView 
     android:id="@+id/stats_transition_txt" 
     style="@style/fragments_textstyles" 
     android:layout_below="@id/stats_distance_img" 
     android:layout_marginLeft="80dp" 
     android:layout_toRightOf="@id/stats_jump_txt" 
     android:text="00" /> 


    <ImageView 
     android:id="@+id/stats_intensity_img" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="40dp" 
     android:layout_toRightOf="@id/stats_transition_img" 
     android:background="@drawable/ic_stats_intensity" /> 


    <TextView 
     android:id="@+id/stats_intensity_txt" 
     style="@style/fragments_textstyles" 
     android:layout_below="@id/stats_distance_img" 
     android:layout_marginLeft="55dp" 
     android:layout_toRightOf="@id/stats_transition_txt" 
     android:text="0000" /> 

</RelativeLayout> 


<RelativeLayout 
    android:id="@+id/stats_symmetric_group" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/statsgroup1" 
    android:layout_marginTop="50dp" 
    android:paddingLeft="30dp" 
    android:paddingRight="30dp"> 


    <TextView 
     android:id="@+id/stats_sym_txt1" 
     style="@style/fragments_textstyles" 
     android:layout_alignParentLeft="true" 
     android:layout_centerVertical="true" 
     android:layout_marginRight="10dp" 
     android:text="50%" /> 


    <ImageView 
     android:id="@+id/stats_symmertic_img" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerVertical="true" 
     android:layout_toRightOf="@id/stats_sym_txt1" 
     android:background="@drawable/ic_stats_symmetric" /> 


    <TextView 

     style="@style/fragments_textstyles" 
     android:layout_centerVertical="true" 
     android:layout_marginLeft="10dp" 
     android:layout_toRightOf="@id/stats_symmertic_img" 
     android:text="50%" /> 


    <RelativeLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true"> 


     <TextView 
      android:id="@+id/stats_rotation_txt1" 
      style="@style/fragments_textstyles" 
      android:layout_alignParentLeft="true" 
      android:layout_marginRight="10dp" 
      android:text="50%" /> 

     <ImageView 
      android:id="@+id/stats_rotation_img" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_toRightOf="@id/stats_rotation_txt1" 
      android:background="@drawable/ic_stats_rotation" /> 


     <TextView 
      android:id="@+id/stats_rotation_txt2" 
      style="@style/fragments_textstyles" 
      android:layout_marginLeft="10dp" 
      android:layout_toRightOf="@id/stats_rotation_img" 
      android:text="50%" /> 


    </RelativeLayout> 

</RelativeLayout> 

+0

여러 개의 xml 레이아웃이 있습니까, 아니면 차이점이 있습니까? – abbath

+0

@abbath 몇 가지 있지만, 지금은 모든 다른 화면에 맞게 하나의 레이아웃 만 얻으려고합니다. – Muddz

+0

여기에 코드를 게시 할 수 있습니까? 어쩌면 정확한 xml 소스에 대해 제안 할 수있는 몇 가지 개선 사항이있을 수 있습니다. – abbath

답변

0

당신이에 대한 using several dimens.xml 파일을 들어 본 적이 있습니까?

갖는 다른 dimens하지만, 하나 개의 레이아웃

하나의 레이아웃을 가질 수 있지만, 당신이 지원하고자 각 크기에 대해 개별적으로 DP 크기를 설명하는 다른 dimens.xml -s의 요소의 크기를 정의 할 수 있습니다 그런 식으로. offical 한 안드로이드 페이지에서 예 : 여러 dimens.xml하지만 페이지에 대한 하나의 layout.xml이있는 경우

<TextView 
    android:layout_height="@dimen/textview_height" 
    android:layout_width="@dimen/textview_width" 
    android:textSize="@dimen/font_size"/> 

는, 그것의 :

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <dimen name="textview_height">25dp</dimen> 
    <dimen name="textview_width">150dp</dimen> 
    <dimen name="ball_radius">30dp</dimen> 
    <dimen name="font_size">16sp</dimen> 
</resources> 

그런 다음 당신은 레이아웃에서 이러한 값을 사용할 수 있습니다 일관되게 변경하기 쉽습니다. 태블릿에 대한

디자인 레이아웃은 태블릿 크기에 사용 smallestWidth 자원을 확인 고려, 쉽게,이 폭 layout-sw600dp/values-sw600dp/ 같은 폴더에 dimens.xml 및/또는 레이아웃을 추가 더 큰 화면을 처리 할 수 ​​있습니다, 또한

크기. More info here

+0

나는 그것을 이미 알고있다! 그러나 예를 들어이 두 값이 완전히 다른 경우를 선택하는 것은 이해할 수 없지만 '1440px x 2560px 640DPI' 및'600px x 1024px 240dpi' – Muddz

+0

에 적합합니다. 그런 다음'480px x 800px 320dpi '및'1440px x 2560px 320DPI '어느 것에는 전혀 들어 맞지 않습니다! 관계가 무엇인지 ... 나는 그것을 얻지 못합니다 .. – Muddz

+0

어떻게 든 묶어서 함께 처리 하시겠습니까? – abbath

관련 문제