- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
<LinearLayout
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="70dp"
xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- MORE BUTTONS HERE -->
<Button
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="Ok"
android:id="@+id/w_save" android:layout_weight="1"/>
<TextView
android:visibility="gone"
android:textColor="@android:color/holo_blue_light"
android:text="Trasa już ustawiona"
android:gravity="center"
android:background="@android:drawable/alert_dark_frame"
android:id="@+id/widget_alreadySet"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
下面是实际测试代码:
@Test
public void widgetButtonPressTest() throws Exception {
ShadowAppWidgetManager appWidgetManager = new ShadowAppWidgetManager();
int widgetId = appWidgetManager.createWidget(NewTripWidgetProvider.class, R.layout.new_trip_widget);
View view = appWidgetManager.getViewFor(widgetId);
Button u1 = (Button) view.findViewById(R.id.w_u1);
u1.performClick();
NewTripWidgetReceiver mWidgetReceiver = mock(NewTripWidgetReceiver.class);
}
当我尝试执行测试时失败并出现以下异常:
android.view.InflateException: XML file .\res\layout\new_trip_widget.xml line #-1 (sorry, not yet implemented): Error inflating class android.widget.TextView
at android.view.LayoutInflater.createView(LayoutInflater.java:620)
at org.robolectric.shadows.RoboLayoutInflater.onCreateView(RoboLayoutInflater.java:38)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at org.robolectric.shadows.ShadowAppWidgetManager.createWidgetView(ShadowAppWidgetManager.java:223)
at org.robolectric.shadows.ShadowAppWidgetManager.createWidgets(ShadowAppWidgetManager.java:205)
at org.robolectric.shadows.ShadowAppWidgetManager.createWidget(ShadowAppWidgetManager.java:189)
at pl.fragoff.gascharger.roboelectrictests.WidgetTest.widgetButtonPressTest(WidgetTest.java:45)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:236)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:158)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
我发现删除以下行可以解决问题:
android:background="@android:drawable/alert_dark_frame"
知道如何在不从 View 中删除 android:backgorund 样式的情况下解决该问题吗?如果有任何帮助,我将不胜感激。
最佳答案
我想通了(如果有人有类似的问题)。
alert_dark_frame.xml 不在我的 android sdk 文件夹中。.../android/sdk/platforms/android-xx/data/res/drawable/alert_dark_frame.xml - 它必须存在。否则它不会工作。
关于java - 解析 android :background ="@android:drawable/alert_dark_frame" 时 Robolectric InflateException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28722091/
我知道如果 Android 在所需的文件夹中找不到图标,它会尽力而为,但我看到有些地方他们建议上述所有内容,而在其他地方他们不包括 drawable ? 那么,如果所有其他的都充满了我的标签图标图像,
这个问题在这里已经有了答案: I am confused with drawable-hdpi and drawable-mdpi (4 个答案) 关闭 9 年前。 我真的很困惑,res下的andr
我正在进行一个非常大的项目,该项目是在 android 1.5 时代开始的。 这个项目随着 android 的发展而发展,目前支持 2.3 及更高版本。 现在我遇到了这个问题,我在 drawable-
所有 Android 文档都提到了“drawable”目录。但是,当我在 Eclipse 中创建 Android 项目时,它不会创建“/res/drawable”目录,但会创建“/res/drawab
我正在使用 Android 1.5,但我现在已迁移到最新版本。所以 Android 1.5 中只有一个“drawable”文件夹,但现在 Android 项目中有三个不同的文件夹用于存储图像。 我发现
当我创建一个新项目时,我的 Android studio 1.0 不显示 drawable-hdpi、drawable-xhdpi、drawable-mdpi 和 drawable-xxhdpi。 我
我将 9-patch 文件从 /drawable 移到了 /drawable-hdpi 因为错误日志推荐使用 drawable-* 提供密度优化图像。 问题是,AppWidget 现在看起来不一样了。
我可以知道这个错误是什么以及对此的解决方案吗?此错误在 Debug模式和 APK 中随机 react 原生应用程序时发生。重现这个错误很困难。 我在 github github-https://git
我能够将不同分辨率的图像保存在 res 文件夹的 drawable-hdpi、drawable-mdpi、drawable-ldpi 中,但不知道如何从 assets/www 文件夹访问图像。请帮忙。
我想为不同的本地化使用不同的图像。但是,我有所有分辨率和所有语言的图像。有没有办法做到这一点? 最佳答案 是的,有可能。可绘制-de-rDE-ldpi,可绘制-de-rDE-mdpi。检查一下。 关于
我的应用程序中有这个可绘制文件夹: 可绘制 drawable-hdpi、mdpi、ldpi、xhdpi 和 xxhdpi。 可绘制-sw240dp-land-xxxhdpi 可绘制-sw360dp-l
背景 我知道可以创建 Drawable(或位图)的旋转版本,因此(关于它的文章 here): @JvmStatic fun getRotateDrawable(d: Drawable, angle:
我有一个可绘制的状态列表,我想从可绘制的状态列表中获取一个特定的可绘制对象: 我为每个键选择正确的可绘制
如果您将可绘制对象放在/drawables 目录中,它们将被缩放,如果您想要不同密度的特定可绘制对象,您需要将它们放在特定目录中(/drawables-hdpi、/drawables-mdpi 等)
我熟悉@drawable,但在我克隆的 repo 中,我发现在引用项目中的可绘制对象时使用了@r$drawable。 对比 最佳答案 “$”(美元符号)用于引用 Android
我使用下面的代码通过手动给每个名称从 drawable 文件夹中获取 9(bird1 到 bird9)图像。 我如何使用数组或将 R.drawable.bird1 替换为变量(因为下面的语句只接受实际
据我了解,Android 的默认 DPI 设置等同于 MDPI。是否有任何理由同时拥有 drawable 和 drawable-mdpi 文件夹,或者如果我只是将它们放在 drawable 中,它们的
有什么区别吗 android:src="@andriod:drawable/filename" 和 android:src="@drawable/filename" 我可以在 xml 文件中以这种方式
我们在项目中提供各种密度的drawables是很常见的 drawable-mdpi drawable-hdpi drawable-xhdpi drawable-xxhdpi drawable-xxxh
我有一个应用程序可以加载用户安装的应用程序并在 recyclerview 中显示列表(应用程序名称和图标)。 此异常在 android 8+ 设备上引发,也不是在所有设备型号上(主要在三星和华为设备上
我是一名优秀的程序员,十分优秀!