Android决定屏幕大小

Android决定屏幕大小,android,Android,我正在开发一个应用程序,它应该支持多个屏幕。对于普通屏幕,我已经在viewflipper中设置了布局,这样图标就不会拥挤。但我想在大屏幕上做的是将所有图标放在一个布局中,而不使用viewflipper来利用屏幕 以下是我的普通屏幕布局: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_heigh

我正在开发一个应用程序,它应该支持多个屏幕。对于普通屏幕,我已经在viewflipper中设置了布局,这样图标就不会拥挤。但我想在大屏幕上做的是将所有图标放在一个布局中,而不使用viewflipper来利用屏幕

以下是我的普通屏幕布局:

<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" />


那么,我怎样才能在大屏幕上做到这一点呢


感谢并再次发布。

您最好使用常规xml文件并将其放置在正确的文件夹中(例如layout xlarge),然后您就可以使用较小尺寸的布局和较大尺寸的布局

程序上也取决于你将要使用的android输出到哪个版本

getResources().getConfiguration()
并使用该方法查找设备屏幕大小是否为

SCREENLAYOUT_SIZE_XLARGE
对于xlarge屏幕(>7英寸) 或

对于大屏幕(4英寸到7英寸之间) 蜂巢(API 11+)之前未定义第一个边界 而第二个边界在某些设备上存在问题

编辑:
我同意FoamyGuy fragments会好得多,特别是因为您可以专门控制每个片段逻辑(例如,为大屏幕创建布局,为小屏幕的片段创建布局(如果您想使用视图翻转器),或者只启动一个新片段,如片段文档中所示的新活动).

是时候让您@FoamyGuy它与2.3兼容吗?如果您使用sdk附带的兼容库(或通过sdk管理器下载),是的,我将它放在layout xlarge文件夹中。但是对于普通屏幕和大屏幕,我只有一个java类。您是在动态填充它们吗?或者您是否已在布局中预先准备好所有要使用的按钮?
SCREENLAYOUT_SIZE_XLARGE
SCREENLAYOUT_SIZE_LARGE