【发布时间】:2016-05-11 17:32:36
【问题描述】:
我正在尝试访问包含一些字符串和可绘制对象的库。在我的主项目中,我将库添加为模块。问题是当我想在布局中引用字符串或颜色资源时,我不能。 根据API语法的指导,我使用@[package.of.the.library]:type/resource_name,但这不起作用。
我添加了一个用于测试的布局示例:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mylibrary="http://schemas.android.com/apk/com.mylibrary.resources"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@mylibrary:string/testing_text" />
</LinearLayout>
我尝试使用xmlns:mylibrary="http://schemas.android.com/apk/res-auto" 代替xmlns:mylibrary="http://schemas.android.com/apk/com.mylibrary.resources",但它不起作用。
【问题讨论】:
标签: android android-resources android-library