c# - Xamarin C# 安卓
问题描述
我正在开发一个 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"
然后我不再收到错误并且我的应用程序运行。
提前致谢。
解决方案
所以事实证明我最终发现了这个问题。
我最终只是做一个解决方法,而不是使用 xml 文件来制作按钮圆形,我打算以编程方式在 C# 中使它们圆形。这行得通,但后来我最终弄清楚了为什么 xml 文件不起作用。
事实证明,我已将文件放在 mipmap/anydpi-v26 文件夹中。我的模拟器试图从它的 mipmap/xhdpi 文件夹中读取,因为它在那里不存在,所以我得到了超时。解决方案是将文件从 mipmap 文件夹中移出并移到不会因设备屏幕大小而改变的文件夹结构中。
希望这可以帮助其他人。
推荐阅读
- excel - 如何执行索引匹配类型过程以复制值并填充列(附加查询)
- scala - 对模拟对象的验证不尊重测试用例
- php - 修复 PHP 中的图像旋转
- sql-server - 如何在 WHERE 语句中使用 Case 或 Coalesce 检查列是否为 NULL
- linux - 命令显示正确,但执行方式不同
- node.js - 如何将多个 ReadableStreams 通过管道传输到单个 WriteStream?
- visual-studio - Visual Studio 解决方案资源管理器 - 观察到资产文件的不同图标
- php - 如何格式化关联数组
- java - 如何在 Java 中使用 ta-lib 修复 RSI 计算输出中的零点?
- laravel - 使用重定向从另一个控制器方法调用 Laravel 控制器方法