2016-06-13 2 views
1

enter image description here안드로이드 화면 오리엔테이션 :

enter image description here

이 방향이 올바르게 여기에 표시됩니다,하지만 난 그것을 실행하고 방향을 가로 모드를 변경하면 작품과 모든 버튼은 enter image description here

로 잘못되어 있지 않습니다

이 문제의 해결 방법은 무엇입니까? 가로 모드 용 XML. 귀하의 이미지 당으로

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
android:background="@drawable/flowers" 
android:id="@+id/frontpage_layout" 

           tools:context="com.example.hassidiczaddic.multiplescreensupport.MainActivity"> 

    <RelativeLayout 

    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/scrollView"> 

    <Button 
    android:layout_width="200dp" 
    android:layout_height="50dp" 
    android:text="OPEN" 
    android:textSize="20sp" 
    android:id="@+id/button.open" 
    android:layout_alignParentTop="true" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" /> 

    <Button 
    android:layout_width="200dp" 
    android:layout_height="50dp" 
    android:text="LARGE" 
    android:textSize="20sp" 
    android:id="@+id/button.large" 
    android:layout_alignParentRight="true" 
    android:layout_marginRight="86dp" 
    android:layout_marginEnd="86dp" 
    android:layout_toRightOf="@+id/button.rate" 
    android:layout_toEndOf="@+id/button.rate" /> 

    <Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textSize="20sp" 

    android:text="Something" 
    android:id="@+id/button.something" 
    android:layout_marginTop="38dp" 
    android:layout_below="@+id/button.open" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" 
    android:layout_toLeftOf="@+id/button.rate" 
    android:layout_toStartOf="@+id/button.rate" /> 

    <Button 
    android:layout_width="wrap_content" 

    android:textSize="20sp" 
    android:layout_height="wrap_content" 
    android:text="RATE" 
    android:id="@+id/button.rate" 
    android:layout_marginTop="38dp" 
    android:layout_below="@+id/button.something" 
    android:layout_toRightOf="@+id/button.open" 
    android:layout_toEndOf="@+id/button.open" /> 

    <Button 
    android:layout_width="wrap_content" 
    android:textSize="20sp" 
    android:layout_height="wrap_content" 
    android:text="CLOSE" 
    android:id="@+id/button.close" 
    android:layout_alignTop="@+id/button.something" 
    android:layout_alignRight="@+id/button.large" 
    android:layout_alignEnd="@+id/button.large" 
    android:layout_toRightOf="@+id/button.rate" 
    android:layout_toEndOf="@+id/button.rate" /> 
    </RelativeLayout> 

    </ScrollView> 
+0

이클립스 태그 란 무엇입니까? –

+1

다르게보아야한다면 레이아웃을 2 개 만듭니다. 하나는 세로 모드 용이고 다른 하나는 가로 모드 용입니다. –

+1

나는 두 개의 xml 레이아웃을 만들었습니다 ... 이미지 게시 대신 – Niroj

답변

1

는 RelativeLayout의를 사용하고 있음을 보여주고 여지가 버튼을 사용할 수 없기 때문에 그것은 중복과 너무 넓 그래서.

더 나은 당신은 다른 화면의 높이를 계산하여 동적으로 버튼의 크기를 조정해야하고 모든 매개 변수 의 부모 RelativeLayout의로있는 ScrollView를 사용합니다.

+1

스크롤보기를 Relativelayout의 부모로 사용했지만 이것도 작동하지 않습니다. – Niroj

+1

@Nirojthapa는 문제의 XML을 게시하여 좀 더 구체적으로 도움을 줄 수 있습니까? – Manifest

+1

나는 xml..please를 추가했다. – Niroj

4

는 OS가 각각 XML 레이아웃 지정된 규정에 따라, 현재의 장치의 하나의 최적 선택 될 주요 활동에 대한 6 다른 레이아웃이 있으며, 규칙은 here 정의된다.

화면 크기가 small/normal/large 인 경우이 레이아웃은 land 레이아웃보다 우선합니다. 실제로 land 레이아웃을 사용하는 유일한 시간은 xlarge 화면에서 실행하는 경우입니다. 그 이유는 layout-land에 정의 된 레이아웃이 사용되기 때문입니다 (자세한 내용은 위 링크를 확인하십시오).

다음 중 한 가지 방법으로이 문제를 해결할 수 있습니다

  1. 이/layout-normal/layout-largelayout-small는 다음 OS는 layout-port & layout-land에서 제공 한보다 사용하기 위해 더 나은 아무것도주의 제거가 사용 layout-small/layout-normal/layout-large 수년간 강하게 낙담 한 경우 Supporting Multiple Screens 문서를 확인해야합니다. 대신 layout-port & layout-land를 사용
  2. 는, XXX는이 레이아웃을 적용하는 최소 높이 인 가능한 높이 한정자 (layout-hXXXdp)를 사용합니다. 예를 들어 layout-h320dp에는 세로 모드에서 폰에 대한 레이아웃이 포함될 수 있으며 레이아웃 XML의 side-by-side 버전을 기본 폴더 (layout)에 넣을 수 있습니다.
  3. ScrollView에 버튼을 넣어서 위의 사항 중 어느 것도 필요하지 않도록 UI 디자인을 다시 작성하십시오.
+1

나는 스크롤 뷰를 상대 레이아웃의 부모로 포함했지만 여전히 출력은 동일합니다. 내 XML 파일은 위에있다. – Niroj

+1

@Nirojthapa 레이아웃이 유효하지 않다고 생각합니다. 기존 ID/button.rate를 참조하고 있습니다. – Kai

+1

@ + id/button.rate는 Button RATE의 ID입니다. – Niroj

관련 문제