android - 尽管 res 文件夹中存在相应的 xml 文件,但无法解析 dimen、mipmap、字符串的符号

标签 android android-resources

android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.android.datafrominternet.MainActivity">

我是 android 开发的新手。

以上是我的 XML 文件的一部分。系统说无法解析符号......对于所有这些。我确实已经将所有维度、字符串写入 res 文件夹中。我无法在我的 XML 文件中访问它们(来自 dimen.xml 或 string.xml 的任何内容)。

AndroidManifest.XML 类似,我无法访问 @mipmap/ic_launcher。虽然我确实在我的 res 文件夹中有它。 我已努力尝试但无法消除错误。

<resources> 
     <!-- Default screen margins, per the Android Design guidelines. -->
     <dimen name="activity_horizontal_margin">16dp</dimen>
     <dimen name="activity_vertical_margin">16dp</dimen>
</resources>

这就是我的 dimen.xml 的样子。同样,string.xml 也定义明确,但它仍然表示无法解析符号

最佳答案

转到项目结构中的res 文件夹,转到values 目录并检查dimen.xml 文件是否存在。如果存在,则初始化您的值,如下所示

<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen> // 16dp is customizable as per your requirement

关于android - 尽管 res 文件夹中存在相应的 xml 文件,但无法解析 dimen、mipmap、字符串的符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48838063/

相关文章:

android - 如何使用 AsyncStorage React Native 缓存 API 数据

android - 为 tegra 平台启动自定义 android 镜像时出错

java - 单击 ListView 然后转到具有自动数据的其他 Activity

android - 将 CardView 高程重置为默认值(静止高程)

android - 为什么 R.color.white 不能在 Color.WHITE 可以工作的地方工作?

java - 无法使用 baseadapter 解析带有 listview 的构造函数适配器

android - 错误 org.json.JSONException : Index 2 out of range

java - 保存按钮|笔记应用

android - 从 XML 资源文件中获取所有字符串资源?

android - R.layout.listview 是否与 R.id.listview 相同