Android模拟器中的平板电脑未正确读取布局。

5

我是一名新手 Android 开发者,正在努力学习如何使用多个布局文件夹为不同尺寸的设备指定不同的布局。

我已经尝试了几种不同的方法,但似乎没有任何东西能让我的模拟平板电脑使用更大的布局。

我的布局目录结构是:

  • layout
  • layout-large
  • layout-sw600dp
  • layout-xlarge

"layout" 文件夹中的 main.xml 是:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
        >
    <SearchView android:id="@+id/searchView"
                android:iconifiedByDefault="false"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>

    <FrameLayout
            android:id="@+id/EarthquakeFragmentContainer"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            />
</LinearLayout>

其他三个文件夹中的main.xml如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:orientation="horizontal">

    <SearchView android:id="@+id/searchView"
                android:iconifiedByDefault="false"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="#FFF"/>

    <fragment android:name="com.paad.earthquake.EarthquakeListFragment"
              android:id="@+id/EarthquakeListFragment"
              android:layout_width="360dp"
              android:layout_height="fill_parent"
            />

    <fragment android:name="com.paad.earthquake.EarthquakeMapFragment"
              android:id="@+id/EarthquakeMapFragment"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
            />

</LinearLayout>

模拟器设置正在尝试模拟Google Nexus 7:

  • 目标:Google APIs(API级别16)
  • 皮肤:WXGA800-7in
  • SD卡:16M
  • 我正在使用皮肤中提供的所有其他选项,以及hw.keyboard=yes和hw.ramSize=512

有人知道为什么这不起作用吗?

谢谢您的帮助!


1
Nexus 7是大型tvdpi设备,因此它将从您提供的layout-large中进行选择。那么问题出在哪里呢?有什么不起作用的地方吗? - Padma Kumar
1
它使用标准“layout”目录下的main.xml,而不是“layout-large”或“layout-sw600dp”目录下的文件。 - user1563784
你确定选择的是213dpi的抽象LCS密度吗? - Padma Kumar
@PadmaKumar,WXGA800-7in图像已经为您完成了这项工作。实际上,它会自动将其设置为213以更好地模拟Nexus 7。;-) - davidcesarino
我的AVD的hw.lcd.density=213,hw.gpu.enabled=yes,如果有区别的话。 - user1563784
显示剩余4条评论
1个回答

0

如果您使用的是10英寸平板电脑和Android 3.2或更高版本,则应该有layout-sw720dp文件夹来存放您的布局文件。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接