将支持库布局属性提取为样式 [英] Extract Support Library layout attributes into styles
问题描述
我正在提取支持库GridLayout
中的视图的样式.
I am extracting styles for views which are inside Support Library's GridLayout
.
因此,我拥有"android"命名空间中的两个属性,例如android:layout_marginLeft="8dp"
和应用"中的属性( http://schemas.android.com/apk/res-auto )一个,例如app:layout_columnSpan="2"
.
Therefore, I have both attributes from the "android" namespace, e.g. android:layout_marginLeft="8dp"
and attributes from the "app" (http://schemas.android.com/apk/res-auto) one, e.g. app:layout_columnSpan="2"
.
首先,当我尝试将属性提取为样式时,Android Studio无法识别应用"中的属性.其次,手动将它们提取到styles.xml中似乎不会对实际布局产生任何影响.因此,是否有可能将支持库属性提取为单独的样式,以及如何提取?
First, Android Studio doesn't recognize the attributes from "app" when I try to extract the attributes as a style. Second, it doesn't seem that extracting them into styles.xml manually brings any effect to the actual layout. So, is it possible to extract the Support Library attributes as a separate style, and how?
推荐答案
我找到了一个类似问题的答案 .相同的解决方案对我有用.
I have found this answer to a similar question. The same solution worked for me.
只需为非"android"属性省略名称空间前缀:
Just leave out the namespace prefix for the non-"android" attributes:
app:layout_columnSpan="2"
变为
<item name="layout_columnSpan">2</item>
样式,不
<item name="app:layout_columnSpan">2</item>
这篇关于将支持库布局属性提取为样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!