2013-03-06 2 views
0

저는 여러 화면을 지원해야하는 애플리케이션을 개발 중입니다. 정상적인 화면에서는 viewflipper 내부에 내 레이아웃을 설정하여 아이콘이 붐비지 않게했습니다. 하지만 큰 화면에서 수행하고자하는 작업은 viewflipper를 사용하지 않고 모든 아이콘을 하나의 레이아웃에 두어 화면을 활용하는 것입니다.안드로이드가 화면 크기를 결정합니다.

가 여기에 일반 화면 내 레이아웃입니다 :

<Button 
    android:id="@+id/ibMedicalAssessment" 
    android:layout_width="110dp" 
    android:layout_height="wrap_content" 
    android:padding="5dp" 
    android:contentDescription="@string/app_name" 
    android:text="@string/medicalassessment" 
    android:textStyle="bold" 
    android:textColor="@color/black" 
    android:layout_margin="20dp" 
    android:background="@drawable/custom_button" 
    android:drawableTop="@drawable/med_assessments" /> 

<Button 
    android:id="@+id/ibProfile" 
    android:layout_width="110dp" 
    android:layout_height="wrap_content" 
    android:padding="5dp" 
    android:contentDescription="@string/app_name" 
    android:text="@string/profile" 
    android:textStyle="bold" 
    android:layout_margin="20dp" 
    android:textColor="@color/black" 
    android:background="@drawable/custom_button" 
    android:drawableTop="@drawable/profile" /> 

</LinearLayout> <!-- 2nd row --> 


</LinearLayout> 


<LinearLayout 
android:background="@color/white" 
android:layout_width="fill_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
android:gravity="center_vertical|center" > 


<LinearLayout 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:orientation="horizontal" > 

<Button 
    android:id="@+id/ibTests" 
    android:layout_width="110dp" 
    android:layout_height="wrap_content" 
    android:padding="5dp" 
    android:contentDescription="@string/app_name" 
    android:text="@string/tests" 
    android:textStyle="bold" 
    android:layout_margin="20dp" 
    android:textColor="@color/black" 
    android:background="@drawable/custom_button" 
    android:drawableTop="@drawable/tests" /> 

<Button 
    android:id="@+id/ibTreatment" 
    android:layout_margin="20dp" 
    android:layout_width="110dp" 
    android:layout_height="wrap_content" 
    android:padding="5dp" 
    android:contentDescription="@string/app_name" 
    android:text="@string/treatment" 
    android:textStyle="bold" 
    android:textColor="@color/black" 
    android:background="@drawable/custom_button" 
    android:drawableTop="@drawable/treatment" /> 


</LinearLayout> 


<LinearLayout 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:orientation="horizontal" > 

<Button 
    android:id="@+id/ibSpecialists" 
    android:layout_width="110dp" 
    android:layout_height="wrap_content" 
    android:padding="5dp" 
    android:contentDescription="@string/app_name" 
    android:text="@string/specialists" 
    android:textStyle="bold" 
    android:layout_margin="20dp" 
    android:textColor="@color/black" 
    android:background="@drawable/custom_button" 
    android:drawableTop="@drawable/specialists" /> 

<Button 
    android:id="@+id/ibDisclaimer" 
    android:layout_margin="20dp" 
    android:layout_width="110dp" 
    android:layout_height="wrap_content" 
    android:padding="5dp" 
    android:contentDescription="@string/app_name" 
    android:text="@string/about" 
    android:textStyle="bold" 
    android:textColor="@color/black" 
    android:background="@drawable/custom_button" 
    android:drawableTop="@drawable/disclaimer" /> 

</LinearLayout> 


</LinearLayout> 

</ViewFlipper> 
</LinearLayout> 

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="@color/lighterred" 
android:layout_gravity="center" 
android:orientation="vertical" > 

<TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:drawableLeft="@drawable/logo" 
    android:layout_gravity="center" 
    android:text="@string/app_name" 
    android:textSize="30sp" 
    android:padding="15dp" 
    android:textStyle="bold" 
    android:textColor="@color/white" 
    android:contentDescription="@string/app_name" /> 

<ViewFlipper 
android:id="@+id/mainFlipper" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" > 

<LinearLayout 
android:background="@color/white" 
android:layout_width="fill_parent" 
android:layout_height="match_parent" 
android:gravity="center_vertical|center" 
android:orientation="vertical" > 


<TextView 
    android:id="@+id/tvMainNote" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textStyle="bold" 
    android:text="@string/slidetoleft" /> 

<LinearLayout 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:orientation="horizontal" > 


<Button 
    android:id="@+id/ibSymptoms" 
    android:layout_width="110dp" 
    android:layout_height="wrap_content" 
    android:padding="5dp" 
    android:contentDescription="@string/app_name" 
    android:text="@string/symptoms" 
    android:textStyle="bold" 
    android:textColor="@color/black" 
    android:layout_margin="20dp" 
    android:background="@drawable/custom_button" 
    android:drawableTop="@drawable/symptoms" /> 

<Button 
    android:id="@+id/ibConditions" 
    android:layout_width="110dp" 
    android:layout_height="wrap_content" 
    android:padding="5dp" 
    android:contentDescription="@string/app_name" 
    android:text="@string/conditions" 
    android:textStyle="bold" 
    android:layout_margin="20dp" 
    android:textColor="@color/black" 
    android:background="@drawable/custom_button" 
    android:drawableTop="@drawable/conditions" /> 
그래서 어떻게 큰 화면에서 할 수 있어요?

감사 및 regrads.

+1

[Fragments의 즐거움을 배울 때가되었습니다] (https://developer.android.com/guide/components/fragments.html) – FoamyGuy

+0

@FoamyGuy 2.3과 호환됩니까? –

+0

sdk와 함께 제공되어야하는 호환성 라이브러리를 사용하는 경우 (또는 sdk 관리자를 통해 다운로드 할 경우) – Raigex

답변

2

일반적으로 일반 xml 파일을 사용하여 올바른 폴더 (예 : layout-xlarge)에 배치하면 더 큰 크기의 레이아웃과 더 큰 크기의 레이아웃이 있습니다.

또한, 프로그램 당신에게 출력 안드로이드 버전에

getResources().getConfiguration() 

을 사용 따라 상기 장치의 스크린 크기가

초대형 화면 용
SCREENLAYOUT_SIZE_XLARGE 

(> 7인치)이면 그 검색하여 또는

SCREENLAYOUT_SIZE_LARGE 

큰 화면 (베팅 ween 4 inch and 7 inches) HoneyComb (API 11+) 전에 첫 번째 경계가 정의되지 않은 반면 두 번째 경계는 특정 장치에 문제가 있습니다.

편집 : FoamyGuy 조각은 특히 각 조각 논리를 구체적으로 제어 할 수 있으므로 (예 : 큰 화면의 레이아웃 만들기 및 작은 화면의 조각 만들기 레이아웃 (원하는 경우 뷰 플리퍼를 사용하거나 프래그먼트 문서에 표시된대로 새 액티비티와 같은 새 프래그먼트를 시작하십시오.

+0

예, layout-xlarge 폴더에 넣습니다. 하지만 나는 일반 스크린과 대형 스크린 모두에 대해 단 하나의 자바 클래스 만 가지고있다. –

+0

동적으로 채우고 있습니까? 미리 준비된 레이아웃에 이미 사용하고 싶은 모든 버튼이 있습니까? – Raigex

관련 문제