android - 我是 Android 开发的新手,当我想为我的 xml 文件添加颜色时,比如@color/white,我被告知“无法解析符号 @color/white”
问题描述
这是我的代码示例;
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
android:background="@color/white"
>
解决方案
您需要导航到res -> values -> colors.xml file check pic here并添加以下代码:
<color name="white">#ffffff</color>
或者您可以直接在线性布局中使用此代码
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
android:background="#ffffff"<!--Change color according to need this is for white-->
>
推荐阅读
- javascript - 如何为深度嵌套的 JSON 创建 Mongoose 模式
- django - 即使 django admin 中有必填字段,也能够保存数据而无需填写内联
- reactjs - 故事书我只能看到 1 个故事,尽管创建了 2 个
- reactjs - TypeError:无法读取 Va 未定义的属性“长度”
- javascript - 向下滚动页面时如何更改标题的颜色?
- behat - Behat 确保选择字段具有这些选项
- cuba-platform - 如何在 cuba 平台实现三点菜单?
- azure - 当我们在天蓝色批处理帐户上创建池时,您如何设置用户身份?
- typescript - 如何使用 TypeScript 中的非可选键子集定义映射类型?
- python - 按值数据框python拆分