【问题标题】:Android tablet in Emulator is not picking up the right layout模拟器中的 Android 平板电脑没有选择正确的布局
【发布时间】:2012-08-25 08:02:31
【问题描述】:

我是 Android 新手,正在尝试学习如何使用多个布局文件夹为不同尺寸的设备指定不同的布局。

我尝试了一些不同的方法,但似乎没有任何效果可以让我的模拟平板电脑使用更大的布局。

我的布局目录结构是:

  • 布局
  • 布局大
  • layout-sw600dp
  • layout-xlarge

“布局”中的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 API(API 级别 16)
  • 皮肤:WXGA800-7in
  • SD 卡:16M
  • 我正在使用皮肤附带的所有其他选项,以及 hw.keyboard=yes 和 hw.ramSize=512

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

感谢您的帮助!

【问题讨论】:

  • nexus 7 是大型 tvdpi 设备,因此它将从您提供的 layout-large 中进行选择。那怎么了?什么不工作?
  • 它使用的是标准“layout”目录中的 main.xml,而不是“layout-large”或“layout-sw600dp”目录。
  • stackoverflow.com/a/11735766/1012284 RU 确定您选择抽象 LCS 密度为 213dpi?
  • @PadmaKumar,WXGA800-7in 图像已经为您做到了。实际上,它会自动将其设置为 213 以更好地模拟 Nexus 7。;-)
  • @DavidCesarino 你是对的。但我可以将值更改为 160,以便从普通布局文件夹中选择,这是我的疑问 :-))

标签: android android-layout android-emulator


【解决方案1】:

如果您使用的是 10" 平板电脑和 android 3.2 或更高版本,您应该有 layout-sw720dp 文件夹来保存您的布局文件

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-11-23
    • 2011-05-10
    • 2011-07-06
    • 1970-01-01
    • 2013-12-09
    • 2013-06-16
    • 1970-01-01
    相关资源
    最近更新 更多