【发布时间】:2014-07-15 07:47:42
【问题描述】:
我正在开发一个 Android 平板电脑应用程序,其中包含许多使用 Theme.Holo.DialogWhenLarge 主题的活动。在真实设备(Nexus 7 KitKat 和 Samsung Galaxy Tab 3 8")上,这些活动按预期显示,但在我尝试创建的 每个 Genymotion 虚拟机上(例如 Nexus 7 KitKat 和 Nexus 10 Jelly Bean)它们显示为正常的全屏活动。我还在使用标准 Android SDK 虚拟设备管理器创建的 Nexus 7 KitKat 模拟器上进行了测试,活动按预期显示。
我可以忽略它并假设它只是 Genymotion 模拟器的问题,但我想知道是否有办法解决这个问题以便拥有更好的测试环境。我想指出 *-large 资源限定符适用于 Genymotion VM,这个问题看起来只与那个主题有关。
为了减少问题的所有可能原因,我创建了一个新的测试项目,其中包含一个正常的主要活动,其中包含一个启动 DialogWhenLarge 主题活动的按钮。我还删除了所有由 Eclipse 自动创建的 Android 支持库和所有 XML 样式文件:剩下的唯一资源是活动的两个布局和启动器图标。这些是测试项目的所有文件:
src/com/example/testdialogwhenlarge/MainActivity.java
package com.example.testdialogwhenlarge;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends Activity {
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
// Start the DialogWhenLarge-themed activity
startActivity(new Intent(MainActivity.this, TestActivity.class));
}
});
}
}
src/com/example/testdialogwhenlarge/TestActivity.java
package com.example.testdialogwhenlarge;
import android.app.Activity;
import android.os.Bundle;
public class TestActivity extends Activity {
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
}
}
res/layout/activity_main.xml
<FrameLayout
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"
tools:context="com.example.testdialogwhenlarge.MainActivity">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</FrameLayout>
res/layout/activity_test.xml
<FrameLayout
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"
tools:context="com.example.testdialogwhenlarge.TestActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</FrameLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testdialogwhenlarge"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="TestDialogWhenLarge"
android:theme="@android:style/Theme.Holo">
<activity android:name="com.example.testdialogwhenlarge.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.testdialogwhenlarge.TestActivity"
android:theme="@android:style/Theme.Holo.DialogWhenLarge">
</activity>
</application>
</manifest>
【问题讨论】:
标签: android android-theme genymotion