【问题标题】:Xamarin C# Android <Timeout exceeded getting exception details>Xamarin C# Android <超时获取异常详细信息>
【发布时间】:2021-04-01 01:08:10
【问题描述】:

我正在开发一个 android 应用程序,但我偶然发现了一个我无法通过的错误。我所有的研究都让我相信我缺少一些 xml 元素,但我不知道是什么,所以希望有更多专业知识的人能指出这一点。

我得到的视觉工作室错误是

Unhandled Exception:

Android.Views.InflateException: <Timeout exceeded getting exception details>

错误来自我的 roundbutton.xml 文件

    <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
  <solid android:color="#536878" />
  <corners android:bottomRightRadius="25dp"
      android:bottomLeftRadius="25dp"
      android:topRightRadius="25dp"
      android:topLeftRadius="25dp"/>
</shape>

我正在从我的主要活动 xml 中调用该代码,而调用上述代码的代码是:

<ImageButton
    android:src="@mipmap/baseline_settings_white_36"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:id="@+id/settingsButton_zone2"
    android:layout_marginBottom="0.0dp"
    android:background = "@mipmap/roundbutton"/>

那么,有人看到我在圆形按钮 xml 中遗漏了什么吗?如果我删除 android:background="@mipmap/roundbutton" 然后我不再收到错误并且我的应用程序运行。

提前致谢。

【问题讨论】:

  • 您是在没有调试器的情况下运行还是仅在调试时才看到超时?如果仅在调试时发生这种情况,那么当您调试时会发生什么 - 日志中有任何内容吗?
  • 我没有尝试不调试,我可以尝试,但我需要调试我的应用程序,所以希望它能够工作。
  • 是的,你肯定需要调试 - 但如果调试只在一种特定情况下失败,那么问题就不是那么大了。

标签: c# android xamarin.android


【解决方案1】:

事实证明我最终找到了问题。

我最终只打算做一个解决方法,而不是使用 xml 文件来制作按钮圆形,我打算以编程方式在 C# 中使它们圆形。这行得通,但后来我最终弄清楚了为什么 xml 文件不起作用。

原来,我已将文件放在 mipmap/anydpi-v26 文件夹中。我的模拟器试图从它的 mipmap/xhdpi 文件夹中读取,因为它在那里不存在,所以我得到了超时。解决方案是将文件从 mipmap 文件夹中移出并移入不会因设备屏幕大小而改变的文件夹结构中。

希望这可以帮助其他人。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多