我试图在layout.xml中获得layout_width
productFlavors {
Free {
resValue "string", "flavored_layout_width", "10dp"
}
}
从gradle构建变体。
<ImageView
android:id="@+id/image"
android:layout_width="@string/flavored_layout_width"
android:layout_height="@string/flavored_layout_height" />
但是它抛出Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: You must supply a layout_width attribute.
Caused by: java.lang.UnsupportedOperationException: Binary XML file line #0: You must supply a layout_width attribute.
仅根据风味创建资源文件夹并将此值包含在dimens文件中会更容易吗?